2019-10-20 18:02:52 +02:00
|
|
|
import i18n from "i18next";
|
2019-10-23 10:26:27 +02:00
|
|
|
// @ts-ignore
|
2019-10-20 18:02:52 +02:00
|
|
|
import Backend from "i18next-fetch-backend";
|
|
|
|
|
import LanguageDetector from "i18next-browser-languagedetector";
|
2019-10-23 10:26:27 +02:00
|
|
|
import { initReactI18next } from "react-i18next";
|
2019-10-20 18:02:52 +02:00
|
|
|
import { urls } from "@scm-manager/ui-components";
|
2019-10-19 16:38:07 +02:00
|
|
|
|
2019-10-20 18:02:52 +02:00
|
|
|
const loadPath = urls.withContextPath("/locales/{{lng}}/{{ns}}.json");
|
2019-10-19 16:38:07 +02:00
|
|
|
|
|
|
|
|
i18n
|
|
|
|
|
.use(Backend)
|
|
|
|
|
.use(LanguageDetector)
|
2019-10-23 10:26:27 +02:00
|
|
|
.use(initReactI18next)
|
2019-10-19 16:38:07 +02:00
|
|
|
.init({
|
2019-10-20 18:02:52 +02:00
|
|
|
fallbackLng: "en",
|
2019-10-19 16:38:07 +02:00
|
|
|
|
|
|
|
|
// try to load only "en" and not "en_US"
|
2019-10-20 18:02:52 +02:00
|
|
|
load: "languageOnly",
|
2019-10-19 16:38:07 +02:00
|
|
|
|
|
|
|
|
// have a common namespace used around the full app
|
2019-10-20 18:02:52 +02:00
|
|
|
ns: ["commons"],
|
|
|
|
|
defaultNS: "commons",
|
2019-10-19 16:38:07 +02:00
|
|
|
|
|
|
|
|
debug: false,
|
|
|
|
|
|
|
|
|
|
interpolation: {
|
2019-10-20 18:02:52 +02:00
|
|
|
escapeValue: false // not needed for react!!
|
2019-10-19 16:38:07 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
react: {
|
2019-10-24 11:31:13 +02:00
|
|
|
wait: true,
|
|
|
|
|
useSuspense: false
|
2019-10-19 16:38:07 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
backend: {
|
|
|
|
|
loadPath: loadPath,
|
|
|
|
|
init: {
|
2019-10-20 18:02:52 +02:00
|
|
|
credentials: "same-origin"
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-19 16:38:07 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default i18n;
|