locl
locl copied to clipboard
Support lazy load locale data at runtime
It would be useful to be able to load the locale
data at bootstrap at the same time of translations.
The solution documented here could be integrated/supported by locl
? A better solution is now available with Angular 9 and $localize
?
Does this code snippet help you?
import { registerLocaleData } from '@angular/common';
/**
* Load the appropriate locale
*/
async function initializeLocale(localeId: string): Promise<void> {
return import(
/* webpackMode: "lazy-once" */
`@angular/common/locales/${localeId}.js`
).then((localeModule) => registerLocaleData(localeModule.default));
}
Then you can call it where you load the translations with locl:
await initializeLocale(translations.locale);