DocSpace-client/products/ASC.Files/Client/src/i18n.js

52 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-02-19 18:57:01 +00:00
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import Backend from "@appserver/common/utils/i18next-http-backend";
2021-02-19 18:57:01 +00:00
import config from "../package.json";
import { LANGUAGE } from "@appserver/common/constants";
import { loadLanguagePath } from "@appserver/common/utils";
2021-02-19 18:57:01 +00:00
const newInstance = i18n.createInstance();
2021-02-19 18:57:01 +00:00
const lng = localStorage.getItem(LANGUAGE) || "en";
2021-02-19 18:57:01 +00:00
newInstance
.use(Backend)
.use(initReactI18next)
.init({
lng: lng,
fallbackLng: "en",
load: "currentOnly",
//debug: true,
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 18:57:01 +00:00
},
ns: [
"DownloadDialog",
"DeleteDialog",
"EmptyTrashDialog",
"ConvertDialog",
"ConnectDialog",
"ConflictResolveDialog",
"DeleteThirdPartyDialog",
"ThirdPartyMoveDialog",
],
backend: {
loadPath: loadLanguagePath(config.homepage),
allowMultiLoading: false,
crossDomain: true,
},
react: {
useSuspense: false,
},
});
2021-02-19 18:57:01 +00:00
export default newInstance;