每次我尝试翻译我都会得到i18next :: translator:missingKey es-AR这是我的哈巴狗组件.pug
.headersGroup
h2(ng-i18next="{{$ctrl.getFilterTitle()}}")
h3(ng-i18next="landing.name")
我试着用两种方式翻译。从帕格文件和控制器。
component.js
getFilterTitle () {
return this.$i18next.t('landing.title')
}
我甚至没有内插或任何东西。只是一个基本的翻译。
是-AR.json
{
"landing": {
"title" : "Filtros",
"name" : "Principales"
}
}
这是我的初学者
window.i18next
.use(window.i18nextXHRBackend);
window.i18next.use(window.i18nextLocalStorageCache);
window.i18next.init({
debug: '!{env}' !== 'production',
lng: config.locale, // If not given, i18n will detect the browser language.
fallbackLng: false,
backend: {
loadPath: '/
myApp/build/i18n/{{lng}}/{{ns}}.json'
},
cache: {
enabled: true,
prefix: 'i18next_experts_',
expirationTime: 7 * 24 * 60 * 60 * 1000,
versions: {}
},
useCookie: false,
useLocalStorage: false
}, function (err, t) {
console.log(err, t);
});
相当确定你在i18next加载翻译之前渲染(调用t
函数)。
检查控制台输出...在收到后端加载消息之前,您是否获得了那些丢失的日志条目?