i18next 将默认翻译命名空间附加到我的命名空间

i18next appends the default translation namespace to my namespaces

我正在使用 i18n - aurelia 的 i18next 包装器,配置如下:

  instance.i18next.use(Backend);

  return instance.setup({
    backend: {
      loadPath: 'assets/locales/{{lng}}/{{ns}}.json',
    },
    detectFromHeaders: false,
    lng: 'bg',
    fallbackLng: 'bg',
    ns: ['app', 'dp', 'management'],
    defaultNS: 'app',
    fallbackNS:'app',
    attributes: ['t', 'i18n'],
    useCookie: false,
    getAsync: false,
    debug: false
  });

我有一个组件可以通过 setLocale(language) 函数切换到不同的语言。它适用于翻译,但是,当我出于某种原因在语言之间切换时,i18next 将 translation.json 添加到我的命名空间,尽管我不使用它并且它会调用 xhr 来获取它并且我得到 404 translation.json 的错误 - 一个我根本不想要的命名空间。是否可以选择将其从命名空间中完全删除? 提前致谢

这是一个已知问题,可以在此处进行跟踪:https://github.com/aurelia/i18n/issues/47

这个问题不是 Aurelia-I18N 的一部分,而是 i18next 本身的问题之一。到目前为止我发现的唯一解决方法是将 fallbackLng 设置为 false。

{
  backend: {                        
    loadPath: './locales/{{lng}}/{{ns}}.json', 
  },
  lng : 'de',
  ns: ['foo'],
  defaultNS: "foo",
  attributes : ['t','i18n'],
  fallbackLng : false,  <----- SET THIS TO FALSE TO AVOID A SEARCH FOR translation NS
  debug : false
}