2023-04-21 11:55:11 +08:00
|
|
|
import i18n from 'i18next';
|
|
|
|
import Backend from 'i18next-xhr-backend';
|
|
|
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
|
|
import { initReactI18next } from 'react-i18next';
|
|
|
|
import { mediaUrl } from '../utils/constants';
|
|
|
|
|
2023-08-28 14:49:26 +08:00
|
|
|
let { lang = 'en' } = window.app.config;
|
|
|
|
lang = lang === 'zh-cn' ? 'zh_cn' : lang; // Compatible with transifex platform
|
2023-04-21 11:55:11 +08:00
|
|
|
|
|
|
|
i18n
|
|
|
|
.use(Backend)
|
|
|
|
.use(LanguageDetector)
|
|
|
|
.use(initReactI18next)
|
|
|
|
.init({
|
|
|
|
lng: lang,
|
|
|
|
fallbackLng: 'en',
|
|
|
|
ns: ['sdoc-editor'],
|
2023-07-22 13:06:46 +08:00
|
|
|
defaultNS: 'sdoc-editor',
|
2023-04-21 11:55:11 +08:00
|
|
|
|
2023-08-28 14:49:26 +08:00
|
|
|
whitelist: ['en', 'zh_CN', 'fr', 'de', 'cs', 'es', 'es-AR', 'es-MX', 'ru'],
|
2023-04-21 11:55:11 +08:00
|
|
|
|
|
|
|
backend: {
|
|
|
|
loadPath: mediaUrl + 'sdoc-editor/locales/{{ lng }}/{{ ns }}.json',
|
|
|
|
// loadPath: '/media/locales/{{lng}}/{{ns}}.json',
|
|
|
|
},
|
|
|
|
|
|
|
|
debug: false, // console log if debug: true
|
|
|
|
|
|
|
|
interpolation: {
|
|
|
|
escapeValue: false, // not needed for react!!
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
load: 'currentOnly',
|
|
|
|
|
|
|
|
react: {
|
|
|
|
wait: true,
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
export default i18n;
|