feat(ivy): use i18n locale data to determine the plural form of ICU expressions (#29249)

Plural ICU expressions depend on the locale (different languages have different plural forms). Until now the locale was hard coded as `en-US`.
For compatibility reasons, if you use ivy with AOT and bootstrap your app with `bootstrapModule` then the `LOCALE_ID` token will be set automatically for ivy, which is then used to get the correct plural form.
If you use JIT, you need to define the `LOCALE_ID` provider on the module that you bootstrap.
For `TestBed` you can use either `configureTestingModule` or `overrideProvider` to define that provider.
If you don't use the compat mode and start your app with `renderComponent` you need to call `ɵsetLocaleId` manually to define the `LOCALE_ID` before bootstrap. We expect this to change once we start adding the new i18n APIs, so don't rely on this function (there's a reason why it's a private export).
PR Close #29249
This commit is contained in:
Olivier Combe
2019-04-11 17:52:55 +02:00
committed by Alex Rickabaugh
parent 6a1441f727
commit 6a8cca7975
27 changed files with 346 additions and 451 deletions

View File

@ -100,6 +100,7 @@ export {
} from './state';
export {
DEFAULT_LOCALE_ID,
ɵɵi18n,
ɵɵi18nAttributes,
ɵɵi18nExp,
@ -109,6 +110,8 @@ export {
ɵɵi18nPostprocess,
i18nConfigureLocalize,
ɵɵi18nLocalize,
getLocaleId,
setLocaleId,
} from './i18n';
export {NgModuleFactory, NgModuleRef, NgModuleType} from './ng_module_ref';