2019-10-20 18:02:52 +02:00
|
|
|
import i18n from "i18next";
|
|
|
|
|
import Backend from "i18next-fetch-backend";
|
|
|
|
|
import LanguageDetector from "i18next-browser-languagedetector";
|
|
|
|
|
import { reactI18nextModule } from "react-i18next";
|
|
|
|
|
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
|
|
|
|
|
|
|
|
// TODO load locales for moment
|
|
|
|
|
|
|
|
|
|
i18n
|
|
|
|
|
.use(Backend)
|
|
|
|
|
.use(LanguageDetector)
|
|
|
|
|
.use(reactI18nextModule)
|
|
|
|
|
.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-20 18:02:52 +02:00
|
|
|
wait: true
|
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;
|