2022-12-24 18:23:21 +00:00
|
|
|
import i18n from 'i18next';
|
|
|
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
|
|
import Backend from 'i18next-http-backend';
|
2023-02-04 00:36:31 +00:00
|
|
|
import { initReactI18next } from 'react-i18next';
|
2023-03-27 14:49:52 +00:00
|
|
|
|
2023-05-05 14:28:00 +00:00
|
|
|
import translationEN from '../dist/locales/en.json';
|
|
|
|
import { LOCALSTORAGE_PREFIX } from 'app/store/constants';
|
2023-03-27 14:49:52 +00:00
|
|
|
|
|
|
|
if (import.meta.env.MODE === 'package') {
|
|
|
|
i18n.use(initReactI18next).init({
|
|
|
|
lng: 'en',
|
|
|
|
resources: {
|
|
|
|
en: { translation: translationEN },
|
2022-12-24 18:23:21 +00:00
|
|
|
},
|
2023-03-27 14:49:52 +00:00
|
|
|
debug: false,
|
2022-12-24 18:23:21 +00:00
|
|
|
interpolation: {
|
|
|
|
escapeValue: false,
|
|
|
|
},
|
|
|
|
returnNull: false,
|
|
|
|
});
|
2023-03-27 14:49:52 +00:00
|
|
|
} else {
|
|
|
|
i18n
|
|
|
|
.use(Backend)
|
2023-05-05 14:28:00 +00:00
|
|
|
.use(
|
|
|
|
new LanguageDetector(null, {
|
|
|
|
lookupLocalStorage: `${LOCALSTORAGE_PREFIX}lng`,
|
|
|
|
})
|
|
|
|
)
|
2023-03-27 14:49:52 +00:00
|
|
|
.use(initReactI18next)
|
|
|
|
.init({
|
|
|
|
fallbackLng: 'en',
|
|
|
|
debug: false,
|
|
|
|
backend: {
|
|
|
|
loadPath: '/locales/{{lng}}.json',
|
|
|
|
},
|
|
|
|
interpolation: {
|
|
|
|
escapeValue: false,
|
|
|
|
},
|
|
|
|
returnNull: false,
|
|
|
|
});
|
|
|
|
}
|
2022-12-24 18:23:21 +00:00
|
|
|
|
|
|
|
export default i18n;
|