Files
SCM-Manager/scm-ui/ui-webapp/src/i18n.ts

45 lines
909 B
TypeScript
Raw Normal View History

import i18n from "i18next";
2019-10-23 10:26:27 +02:00
// @ts-ignore
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";
import { urls } from "@scm-manager/ui-components";
const loadPath = urls.withContextPath("/locales/{{lng}}/{{ns}}.json");
// TODO load locales for moment
i18n
.use(Backend)
.use(LanguageDetector)
2019-10-23 10:26:27 +02:00
.use(initReactI18next)
.init({
fallbackLng: "en",
// try to load only "en" and not "en_US"
load: "languageOnly",
// have a common namespace used around the full app
ns: ["commons"],
defaultNS: "commons",
debug: false,
interpolation: {
escapeValue: false // not needed for react!!
},
react: {
wait: true
},
backend: {
loadPath: loadPath,
init: {
credentials: "same-origin"
}
}
});
export default i18n;