【问题标题】:i18next always returning missing keyi18next 总是返回丢失的密钥
【发布时间】: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);
        });

【问题讨论】:

    标签: angularjs i18next


    【解决方案1】:

    确定在 i18next 加载翻译之前渲染(调用 t 函数)。

    检查控制台输出...您是否在后端加载消息之前获得了那些丢失的日志条目?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-09
      • 2021-10-20
      • 2016-01-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-18
      相关资源
      最近更新 更多