DocSpace-client/web/ASC.Web.Client/src/i18n.js

33 lines
779 B
JavaScript
Raw Normal View History

2021-02-19 17:26:41 +00:00
import i18n from "i18next";
import Backend from "i18next-http-backend";
import config from "../package.json";
import { LANGUAGE } from "@appserver/common/constants";
import { loadLanguagePath } from "@appserver/common/utils";
2021-02-19 17:26:41 +00:00
const newInstance = i18n.createInstance();
2021-02-19 17:26:41 +00:00
newInstance.use(Backend).init({
lng: localStorage.getItem(LANGUAGE) || "en",
fallbackLng: "en",
load: "currentOnly",
//debug: true,
2021-02-19 17:26:41 +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-02-19 17:26:41 +00:00
backend: {
loadPath: loadLanguagePath(config.homepage),
},
react: {
useSuspense: false,
},
});
2021-02-19 17:26:41 +00:00
export default newInstance;