2021-02-19 17:26:41 +00:00
|
|
|
import i18n from "i18next";
|
|
|
|
import Backend from "i18next-http-backend";
|
|
|
|
import config from "../package.json";
|
2021-02-25 14:20:11 +00:00
|
|
|
import { LANGUAGE } from "@appserver/common/constants";
|
2021-06-02 10:55:11 +00:00
|
|
|
import { loadLanguagePath } from "@appserver/common/utils";
|
2021-02-19 17:26:41 +00:00
|
|
|
|
2021-03-04 16:09:46 +00:00
|
|
|
const newInstance = i18n.createInstance();
|
2021-02-19 17:26:41 +00:00
|
|
|
|
2021-03-04 16:09:46 +00:00
|
|
|
newInstance.use(Backend).init({
|
|
|
|
lng: localStorage.getItem(LANGUAGE) || "en",
|
|
|
|
fallbackLng: "en",
|
2021-11-10 16:59:03 +00:00
|
|
|
load: "currentOnly",
|
2021-06-02 10:55:11 +00:00
|
|
|
//debug: true,
|
2021-02-19 17:26:41 +00:00
|
|
|
|
2021-03-04 16:09:46 +00:00
|
|
|
interpolation: {
|
|
|
|
escapeValue: false, // not needed for react as it escapes by default
|
|
|
|
format: function (value, format) {
|
|
|
|
if (format === "lowercase") return value.toLowerCase();
|
|
|
|
return value;
|
2021-02-19 17:26:41 +00:00
|
|
|
},
|
2021-03-04 16:09:46 +00:00
|
|
|
},
|
2021-02-19 17:26:41 +00:00
|
|
|
|
2021-03-04 16:09:46 +00:00
|
|
|
backend: {
|
2021-06-02 10:55:11 +00:00
|
|
|
loadPath: loadLanguagePath(config.homepage),
|
2021-03-04 16:09:46 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
react: {
|
|
|
|
useSuspense: false,
|
|
|
|
},
|
|
|
|
});
|
2021-02-19 17:26:41 +00:00
|
|
|
|
2021-03-04 16:09:46 +00:00
|
|
|
export default newInstance;
|