Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// keySeparator: false,
// common namespace for the app
ns: ['translations', 'ldml'],
defaultNS: 'translations',
// debug: true,
interpolation: {
// react already does escaping
escapeValue: false,
},
});
i18n.addResourceBundle('es-419', 'translations', esLa, true, true);
i18n.addResourceBundle('en-US', 'translations', enUs, true, true);
i18n.addResourceBundle('fr-FR', 'translations', frFR, true, true);
export default i18n;
function addResourceBundle(lng, ns, resources) {
i18n.addResourceBundle(lng, ns, resources);
}
addLanguage(code, lang, active = false) {
i18next.addResourceBundle(code, 'translation', lang, true, true);
if (active) {
this.language = code;
}
}
return new Promise((resolve?: any, reject?: any) => {
if (resource.name && resource.code) {
if (this.loadedLanguages.includes(resource.code)) {
reject();
} else {
i18next.addResourceBundle(
resource.code,
"translation",
resource.words,
true,
true
);
this.loadedLanguages.push(resource.code);
i18next.changeLanguage(resource.code).then(() => {
resolve(resource.code);
});
}
} else {
reject();
}
});
}
export function addTranslationResource(lang, translations) {
i18next.addResourceBundle(lang, 'translation', translations, true, false)
}
Object.keys(newLocales[key]).map(namespace => {
const locale = newLocales[key][namespace];
resourceBundle.push({ key, namespace, locale });
i18n.addResourceBundle(key, namespace, locale, true, true);
});
});
return (target: any) => {
if (!i18next.isInitialized) {
Translation(undefined, undefined, () => {
i18next.addResourceBundle(locale, namespace, catalog, true, true);
});
} else {
i18next.addResourceBundle(locale, namespace, catalog, true, true);
}
return target;
}
}
(resources) => {
i18n.addResourceBundle(i18n.language, ns.toLowerCase(), resources, true, true);
},
];
const loadLocales = () => {
i18next.addResourceBundle('en', 'modulesDocs', {
metadata: {
name: 'modulesDocs',
displayName: 'Modules Docs Module',
description: 'This module shows the very basic usage of Bractal, and it simply does only one job, which is loading and showing all home pages of all the loaded modules',
},
home: {
menuTitle: 'Modules Docs',
},
}, true, true);
i18next.loadNamespaces('modulesDocs');
};
(resources: ObjectOf) => {
i18n.addResourceBundle(
i18n.language, ns.toLowerCase(), resources, true, true,
);
},
];