【发布时间】:2018-06-02 05:32:45
【问题描述】:
每次我尝试翻译时都会得到 i18next::translator: missingKey es-AR 这是我的哈巴狗 component.pug
.headersGroup
h2(ng-i18next="{{$ctrl.getFilterTitle()}}")
h3(ng-i18next="landing.name")
我尝试用两种方式翻译。来自 pug 文件和控制器。
component.js
getFilterTitle () {
return this.$i18next.t('landing.title')
}
我什至没有插值或任何东西。只是一个基本的翻译。
es-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);
});
【问题讨论】: