MCPcopy Index your code
hub / github.com/angular/angular / getPluralCategory

Function getPluralCategory

packages/common/src/i18n/localization.ts:34–60  ·  view source on GitHub ↗
(
  value: number,
  cases: string[],
  ngLocalization: NgLocalization,
  locale?: string,
)

Source from the content-addressed store, hash-verified

32 * - the plural category otherwise
33 */
34export function getPluralCategory(
35 value: number,
36 cases: string[],
37 ngLocalization: NgLocalization,
38 locale?: string,
39): string {
40 let key = `=${value}`;
41
42 if (cases.indexOf(key) > -1) {
43 return key;
44 }
45
46 key = ngLocalization.getPluralCategory(value, locale);
47
48 if (cases.indexOf(key) > -1) {
49 return key;
50 }
51
52 if (cases.indexOf('other') > -1) {
53 return 'other';
54 }
55
56 throw new RuntimeError(
57 RuntimeErrorCode.NO_PLURAL_MESSAGE_FOUND,
58 ngDevMode && `No plural message found for value "${value}"`,
59 );
60}
61
62/**
63 * Returns the plural case based on the locale

Callers 3

_updateViewMethod · 0.90
transformMethod · 0.90

Calls 2

indexOfMethod · 0.80
getPluralCategoryMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…