Web:Login:Server:i18n: import locales as resources
This commit is contained in:
parent
500d1fe09b
commit
e8cdfd6213
@ -1,15 +1,23 @@
|
||||
import i18next from "i18next";
|
||||
import Backend from "i18next-fs-backend";
|
||||
import { loadPath } from "./lib/helpers";
|
||||
|
||||
import { translations } from "SRC_DIR/autoGeneratedTranslations";
|
||||
|
||||
const fallbackLng = "en";
|
||||
|
||||
i18next.use(Backend).init({
|
||||
backend: {
|
||||
loadPath: loadPath,
|
||||
allowMultiLoading: true,
|
||||
crossDomain: false,
|
||||
},
|
||||
const resources: {
|
||||
[key: string]: { [key: string]: {} };
|
||||
} = {};
|
||||
|
||||
translations.forEach((lngCol: Map<string, {}>, key: string) => {
|
||||
resources[key] = {};
|
||||
lngCol.forEach((data, ns: string) => {
|
||||
if (resources[key]) {
|
||||
resources[key][ns] = data;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
i18next.init({
|
||||
fallbackLng: fallbackLng,
|
||||
load: "currentOnly",
|
||||
|
||||
@ -17,6 +25,8 @@ i18next.use(Backend).init({
|
||||
ns: ["Login", "Common"],
|
||||
defaultNS: "Login",
|
||||
|
||||
resources,
|
||||
|
||||
interpolation: {
|
||||
escapeValue: false,
|
||||
format: function (value, format) {
|
||||
|
Loading…
Reference in New Issue
Block a user