refactor(i18n): I18nPipe uses NgLocalization (#9313)

and some refactoring
This commit is contained in:
Victor Berchet
2016-06-23 11:44:05 -07:00
committed by GitHub
parent 54dbed4f48
commit fed1672a43
11 changed files with 76 additions and 81 deletions

View File

@ -0,0 +1,18 @@
/**
* @experimental
*/
export abstract class NgLocalization { abstract getPluralCategory(value: any): string; }
/**
* Returns the plural category for a given value.
* - "=value" when the case exists,
* - the plural category otherwise
*
* @internal
*/
export function getPluralCategory(
value: number, cases: string[], ngLocalization: NgLocalization): string {
const nbCase = `=${value}`;
return cases.indexOf(nbCase) > -1 ? nbCase : ngLocalization.getPluralCategory(value);
}