React i18next修改翻译文件路径

问题描述 投票:0回答:1

我正在使用带有 react-i18next 的 React 应用程序,我正在从路径加载翻译

locales/en/translation.json
locales/de/translation.json
locales/fr/translation.json
...

我可以更改路径并从中加载翻译吗

lib/en.i18n.json
lib/de.i18n.json
lib/fr.i18n.json
...

非常感谢

javascript reactjs translation i18next
1个回答
0
投票

更新您的 i18n 库的配置。

import i18n from 'i18next';
import XHR from 'i18next-xhr-backend';

i18n
  .use(XHR)
  .init({
    backend: {
      loadPath: 'lib/{{lng}}.i18n.json',
    },
    // ... other i18n options ...
  });

© www.soinside.com 2019 - 2024. All rights reserved.