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:

committed by
Matias Niemelä

parent
f5b0c8a323
commit
5e0f982961
@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
import '../util/ng_dev_mode';
|
||||
|
||||
import {ChangeDetectionStrategy} from '../change_detection/constants';
|
||||
import {NG_INJECTABLE_DEF, ɵɵdefineInjectable} from '../di/interface/defs';
|
||||
import {Mutable, Type} from '../interface/type';
|
||||
@ -16,9 +15,8 @@ import {SchemaMetadata} from '../metadata/schema';
|
||||
import {ViewEncapsulation} from '../metadata/view';
|
||||
import {noSideEffects} from '../util/closure';
|
||||
import {stringify} from '../util/stringify';
|
||||
|
||||
import {EMPTY_ARRAY, EMPTY_OBJ} from './empty';
|
||||
import {NG_BASE_DEF, NG_COMPONENT_DEF, NG_DIRECTIVE_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from './fields';
|
||||
import {NG_BASE_DEF, NG_COMPONENT_DEF, NG_DIRECTIVE_DEF, NG_LOCALE_ID_DEF, NG_MODULE_DEF, NG_PIPE_DEF} from './fields';
|
||||
import {ComponentDef, ComponentDefFeature, ComponentTemplate, ComponentType, ContentQueriesFunction, DirectiveDef, DirectiveDefFeature, DirectiveType, DirectiveTypesOrFactory, FactoryFn, HostBindingsFunction, PipeDef, PipeType, PipeTypesOrFactory, ViewQueriesFunction, ɵɵBaseDef} from './interfaces/definition';
|
||||
// while SelectorFlags is unused here, it's required so that types don't get resolved lazily
|
||||
// see: https://github.com/Microsoft/web-build-tools/issues/1050
|
||||
@ -779,3 +777,7 @@ export function getNgModuleDef<T>(type: any, throwNotFound?: boolean): NgModuleD
|
||||
}
|
||||
return ngModuleDef;
|
||||
}
|
||||
|
||||
export function getNgLocaleIdDef(type: any): string|null {
|
||||
return (type as any)[NG_LOCALE_ID_DEF] || null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user