Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function initializeTranslation(translateService: TranslateService, dateAdapter: DateAdapter): void {
translateService.addLangs(["en", "fr", "nl"]);
translateService.setDefaultLang("en");
translateService.use("en");
// set the Moment language, otherwise it is set by the last imported locale!
moment.locale("en"); // in fact Moment default language is US English
dateAdapter.setLocale("en"); // US English locale in Moment is just "en"
const english: StarkLocale = { languageCode: "en", translations: translationsEn };
const french: StarkLocale = { languageCode: "fr", translations: translationsFr };
const dutch: StarkLocale = { languageCode: "nl", translations: translationsNl };
mergeTranslations(translateService, english, french, dutch);
}export function mergeUiTranslations(translateService: TranslateService, ...localesToMerge: StarkLocale[]): void {
const allLocalesToMerge: StarkLocale[] = [];
// the common UI translations are merged with the given locales before calling the mergeTranslations from Stark-Core
for (const locale of localesToMerge) {
allLocalesToMerge.push({
languageCode: locale.languageCode,
translations: merge({}, commonUiTranslations[locale.languageCode], locale.translations)
});
}
// finally the mergeTranslations from Stark-Core merges all the locales (common UI + given locales)
mergeTranslations(translateService, ...allLocalesToMerge);
}* The English StarkLocale, composed of the "en" language code
* and an object that retrieves all the English translations for the application in a json file
*/
const english: StarkLocale = { languageCode: "en", translations: translationsEn };
/**
* The French StarkLocale, composed of the "fr" language code
* and an object that retrieves all the French translations for the application in a json file
*/
const french: StarkLocale = { languageCode: "fr", translations: translationsFr };
/**
* The Dutch StarkLocale, composed of the "nl" language code
* and an object that retrieves all the Dutch translations for the application in a json file
*/
const dutch: StarkLocale = { languageCode: "nl", translations: translationsNl };
mergeTranslations(translateService, english, french, dutch);
}