当vue-i18n 找不到某个翻译时,它会触发一个 missing 回调。你可以在这个回调中添加自定义的逻辑,如输出警告信息或发送日志给开发团队。同时,你也可以启用严格模式来确保所有翻译都被正确提供: javascript const i18n = createI18n({ locale: 'en', messages, missing: (locale, key, instance) => { consol...
homeAddress:'Home address', missingHomeAddress:'Please provide @.lower:message.homeAddress'} } } {{$t('message.homeAddress') }} {{$t('message.missingHomeAddress') }} 输出以下内容: Home addressPlease provide home address 您可以添加修饰符或覆盖将modifiers选项传递给 VueI18n 构造函数的现有修饰...
missing?: MissingHandler; fallbackRoot?: boolean; fallbackRootWithEmptyString?: boolean, formatFallbackMessages?: boolean; sync?: boolean; silentTranslationWarn?: boolean | RegExp; silentFallbackWarn?: boolean | RegExp; preserveDirectiveContent?: boolean; pluralizationRules?: Pluralization...
set fallbackLocale (locale: string): void { this._fallbackLocale = locale } get missing (): ?MissingHandler { return this._missing } set missing (handler: MissingHandler): void { this._missing = handler } get formatter (): Formatter { return this._formatter } // get 转换函数 set fo...
775 * @VueI18nSee [missing](composition#posttranslation) 776 */ 777 getPostTranslationHandler(): PostTranslationHandler<Message> | null; 778 /** 779 * Set post translation handler 780 * 781 * @param handler - A {@link PostTranslationHandler} 782 * 783 * @VueI18nSee [missing...
locale) } // 获取当前vm的fallbackLocale属性的内容 get fallbackLocale (): Locale { return this._vm.fallbackLocale } // 设置当前vm的fallbackLocale属性的内容 set fallbackLocale (locale: Locale): void { this._vm.$set(this._vm, 'fallbackLocale', locale) } // 同上 get missing (): ?
constmessages={en:{message:{homeAddress:'Home address',missingHomeAddress:'Please provide @.lower:message.homeAddress'} } } 可以添加修饰符或覆盖将 modifiers 选项传递给 VueI18n 构造函数的现有修饰符。 consti18n =newVueI18n({locale:'en',modifiers: {snakeCase:(str) =>str.split(' ').join('-...
Reporting a bug? I try to translate a key through the MissingHandler with vuei18n, but I get the following error: vm.$t is not a function. My goal is to ensure that a key is replaced, with a parent key, if it is not found. Expected behav...
from"vue-i18n"importglobalLangfrom"./lang/globalLang"constlang=newURLSearchParams(location.search.substr(1)).get("lang")||"zh"constapp=createApp(App)consti18n=createI18n({legacy:false,locale:lang,fallbakLocale:"en",silentTranslationWarn:true,messages:globalLang,fallbackWarn:false,missingWarn:...
1.远程加载翻译文件 vari18n =newVueI18n({locale:"zh",silentTranslationWarn:true,//没有的key值不发出警告missing(){//没有key值时应如何处理return""; } })varapp =newVue({ i18n,el:"#app"})vartest =newVue({ i18n,el:"#test"})