feat(ivy): allow the locale to be set via a global property (#33314)

In the post-$localize world the current locale value is defined by setting
`$localize.locale` which is then read at runtime by Angular in the provider
for the `LOCALE_ID` token and also passed to the ivy machinery via`setLocaleId()`.

The $localize compile-time inlining tooling can replace occurrences of
`$localize.locale` with a string literal, similar to how translations
are inlined.

// FW-1639

See https://github.com/angular/angular-cli/issues/15896

PR Close #33314
This commit is contained in:
Pete Bacon Darwin
2019-10-23 22:49:02 +01:00
committed by Andrew Kushnir
parent ed4244e932
commit fde8363e0d
3 changed files with 109 additions and 12 deletions

View File

@ -20,6 +20,22 @@ export interface LocalizeFn {
* different translations.
*/
translate?: TranslateFn;
/**
* The current locale of the translated messages.
*
* The compile-time translation inliner is able to replace the following code:
*
* ```
* $localize && $localize.locale
* ```
*
* with a string literal of the current locale. E.g.
*
* ```
* "fr"
* ```
*/
locale?: string;
}
export interface TranslateFn {