Locale
The app's locale from the host app, as a signal and as Angular's LOCALE_ID. import { LynxLocale, provideLocale, getLynxAppLocale } from '@blotch/angular-lynx';
Usage
src/app/app.config.ts
ng generate @blotch/angular-lynx:add-i18n adds provideLocale() for you.
API
provideLocale()
Provides Angular's LOCALE_ID from LynxLocale.locale(), so pipes such as DatePipe and CurrencyPipe format for that locale.
- Read once.
LOCALE_IDtakes the locale when the app starts. A later change doesn't reformat pipes.
getLynxAppLocale()
Returns the host's appLocale value without Angular. Use it in main.ts before bootstrapApplication(), where no injector exists yet. For example, choose which translations to load.
- Returns
undefinedoutside Lynx, or when the host sets no locale.
src/main.ts
LynxLocale
The current locale as a signal.
LynxLocale.locale
The locale, chosen in this order:
- The
appLocaleglobal value the host app sets, such as'fr-FR'. - The
i18n.sourceLocalefrom yourangular.json. 'en-US'.
Types
None of its own.
Related
- Internationalization: translations and locale-aware formatting.
- Host data
- Angular i18n
