
In `BrowserModule` the value of `LOCALE_ID` is defined in the `APPLICATION_MODULE_PROVIDERS` after `APP_INITIALIZER` has run. This PR ensures that `LOCALE_ID` is also set for ivy at the same moment which allows the application to fetch the locale from a backend (for example). Fixes #31465 FW-1436 #resolve PR Close #31566
37 lines
809 B
TypeScript
37 lines
809 B
TypeScript
/**
|
|
* @license
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
import {getLocalePluralCase} from './locale_data_api';
|
|
|
|
/**
|
|
* Returns the plural case based on the locale
|
|
*/
|
|
export function getPluralCase(value: any, locale: string): string {
|
|
const plural = getLocalePluralCase(locale)(value);
|
|
|
|
switch (plural) {
|
|
case 0:
|
|
return 'zero';
|
|
case 1:
|
|
return 'one';
|
|
case 2:
|
|
return 'two';
|
|
case 3:
|
|
return 'few';
|
|
case 4:
|
|
return 'many';
|
|
default:
|
|
return 'other';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* The locale id that the application is using by default (for translations and ICU expressions).
|
|
*/
|
|
export const DEFAULT_LOCALE_ID = 'en-US';
|