2018-10-25 06:52:03 +00:00
|
|
|
import i18n from 'i18next';
|
2020-05-22 14:06:05 +00:00
|
|
|
import { initReactI18next } from 'react-i18next';
|
2018-10-25 06:52:03 +00:00
|
|
|
import langDetect from 'i18next-browser-languagedetector';
|
2018-11-16 09:45:41 +00:00
|
|
|
|
2020-01-31 12:57:20 +00:00
|
|
|
import { LANGUAGES, BASE_LOCALE } from './helpers/twosky';
|
2019-10-21 10:09:52 +00:00
|
|
|
|
2020-09-16 14:42:57 +00:00
|
|
|
import be from './__locales/be.json';
|
2020-02-04 10:37:35 +00:00
|
|
|
import bg from './__locales/bg.json';
|
|
|
|
import cs from './__locales/cs.json';
|
|
|
|
import da from './__locales/da.json';
|
|
|
|
import de from './__locales/de.json';
|
2020-09-16 14:42:57 +00:00
|
|
|
import en from './__locales/en.json';
|
|
|
|
import es from './__locales/es.json';
|
|
|
|
import fa from './__locales/fa.json';
|
2021-11-15 11:35:46 +00:00
|
|
|
import fi from './__locales/fi.json';
|
2020-09-16 14:42:57 +00:00
|
|
|
import fr from './__locales/fr.json';
|
|
|
|
import hr from './__locales/hr.json';
|
|
|
|
import hu from './__locales/hu.json';
|
2020-02-04 10:37:35 +00:00
|
|
|
import id from './__locales/id.json';
|
|
|
|
import it from './__locales/it.json';
|
2020-09-16 14:42:57 +00:00
|
|
|
import ja from './__locales/ja.json';
|
2020-02-04 10:37:35 +00:00
|
|
|
import ko from './__locales/ko.json';
|
|
|
|
import nl from './__locales/nl.json';
|
2020-09-16 14:42:57 +00:00
|
|
|
import no from './__locales/no.json';
|
2020-02-04 10:37:35 +00:00
|
|
|
import pl from './__locales/pl.json';
|
2020-09-16 14:42:57 +00:00
|
|
|
import ptBR from './__locales/pt-br.json';
|
2020-02-04 10:37:35 +00:00
|
|
|
import ptPT from './__locales/pt-pt.json';
|
2020-09-16 14:42:57 +00:00
|
|
|
import ro from './__locales/ro.json';
|
|
|
|
import ru from './__locales/ru.json';
|
|
|
|
import siLk from './__locales/si-lk.json';
|
2020-02-04 10:37:35 +00:00
|
|
|
import sk from './__locales/sk.json';
|
|
|
|
import sl from './__locales/sl.json';
|
|
|
|
import srCS from './__locales/sr-cs.json';
|
2020-09-16 14:42:57 +00:00
|
|
|
import sv from './__locales/sv.json';
|
2020-03-11 14:06:17 +00:00
|
|
|
import th from './__locales/th.json';
|
2020-09-16 14:42:57 +00:00
|
|
|
import tr from './__locales/tr.json';
|
2021-11-15 11:35:46 +00:00
|
|
|
import uk from './__locales/uk.json';
|
2020-09-16 14:42:57 +00:00
|
|
|
import vi from './__locales/vi.json';
|
|
|
|
import zhCN from './__locales/zh-cn.json';
|
|
|
|
import zhHK from './__locales/zh-hk.json';
|
|
|
|
import zhTW from './__locales/zh-tw.json';
|
2020-07-03 08:14:54 +00:00
|
|
|
import { setHtmlLangAttr } from './helpers/helpers';
|
2020-02-04 10:37:35 +00:00
|
|
|
|
|
|
|
const resources = {
|
2021-11-15 11:35:46 +00:00
|
|
|
be: { translation: be },
|
|
|
|
bg: { translation: bg },
|
|
|
|
cs: { translation: cs },
|
|
|
|
da: { translation: da },
|
|
|
|
de: { translation: de },
|
|
|
|
en: { translation: en },
|
|
|
|
'en-us': { translation: en },
|
|
|
|
es: { translation: es },
|
|
|
|
fa: { translation: fa },
|
|
|
|
fi: { translation: fi },
|
|
|
|
fr: { translation: fr },
|
|
|
|
hr: { translation: hr },
|
|
|
|
hu: { translation: hu },
|
|
|
|
id: { translation: id },
|
|
|
|
it: { translation: it },
|
|
|
|
ja: { translation: ja },
|
|
|
|
ko: { translation: ko },
|
|
|
|
nl: { translation: nl },
|
|
|
|
no: { translation: no },
|
|
|
|
pl: { translation: pl },
|
|
|
|
'pt-br': { translation: ptBR },
|
|
|
|
'pt-pt': { translation: ptPT },
|
|
|
|
ro: { translation: ro },
|
|
|
|
ru: { translation: ru },
|
|
|
|
'si-lk': { translation: siLk },
|
|
|
|
sk: { translation: sk },
|
|
|
|
sl: { translation: sl },
|
|
|
|
'sr-cs': { translation: srCS },
|
|
|
|
sv: { translation: sv },
|
|
|
|
th: { translation: th },
|
|
|
|
tr: { translation: tr },
|
|
|
|
uk: { translation: uk },
|
|
|
|
vi: { translation: vi },
|
|
|
|
'zh-cn': { translation: zhCN },
|
|
|
|
'zh-hk': { translation: zhHK },
|
|
|
|
'zh-tw': { translation: zhTW },
|
2020-02-04 10:37:35 +00:00
|
|
|
};
|
|
|
|
|
2020-01-31 12:57:20 +00:00
|
|
|
const availableLanguages = Object.keys(LANGUAGES);
|
2019-10-21 10:09:52 +00:00
|
|
|
|
2018-10-25 06:52:03 +00:00
|
|
|
i18n
|
|
|
|
.use(langDetect)
|
2020-05-22 14:06:05 +00:00
|
|
|
.use(initReactI18next)
|
2018-10-25 06:52:03 +00:00
|
|
|
.init({
|
2020-02-04 10:37:35 +00:00
|
|
|
resources,
|
2019-10-21 13:03:17 +00:00
|
|
|
lowerCaseLng: true,
|
2020-01-31 12:57:20 +00:00
|
|
|
fallbackLng: BASE_LOCALE,
|
2019-10-21 10:09:52 +00:00
|
|
|
keySeparator: false,
|
|
|
|
nsSeparator: false,
|
|
|
|
returnEmptyString: false,
|
2018-10-25 06:52:03 +00:00
|
|
|
interpolation: {
|
2019-10-21 10:09:52 +00:00
|
|
|
escapeValue: false,
|
2018-10-25 06:52:03 +00:00
|
|
|
},
|
|
|
|
react: {
|
|
|
|
wait: true,
|
|
|
|
},
|
2020-01-31 12:57:20 +00:00
|
|
|
whitelist: availableLanguages,
|
2020-07-03 08:14:54 +00:00
|
|
|
},
|
|
|
|
() => {
|
2019-10-21 13:03:17 +00:00
|
|
|
if (!availableLanguages.includes(i18n.language)) {
|
2020-01-31 12:57:20 +00:00
|
|
|
i18n.changeLanguage(BASE_LOCALE);
|
2019-10-21 13:03:17 +00:00
|
|
|
}
|
2020-07-03 08:14:54 +00:00
|
|
|
setHtmlLangAttr(i18n.language);
|
2018-10-25 06:52:03 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
export default i18n;
|