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

Method transform

packages/common/src/pipes/i18n_plural_pipe.ts:46–60  ·  view source on GitHub ↗

* @param value the number to be formatted * @param pluralMap an object that mimics the ICU format, see * https://unicode-org.github.io/icu/userguide/format_parse/messages/. * @param locale a `string` defining the locale to use (uses the current LOCALE_ID by * default).

(
    value: number | null | undefined,
    pluralMap: {[count: string]: string},
    locale?: string,
  )

Source from the content-addressed store, hash-verified

44 * default).
45 */
46 transform(
47 value: number | null | undefined,
48 pluralMap: {[count: string]: string},
49 locale?: string,
50 ): string {
51 if (value == null) return '';
52
53 if (typeof pluralMap !== 'object' || pluralMap === null) {
54 throw invalidPipeArgumentError(I18nPluralPipe, pluralMap);
55 }
56
57 const key = getPluralCategory(value, Object.keys(pluralMap), this._localization, locale);
58
59 return pluralMap[key].replace(_INTERPOLATION_REGEXP, value.toString());
60 }
61}

Callers

nothing calls this directly

Calls 5

invalidPipeArgumentErrorFunction · 0.90
getPluralCategoryFunction · 0.90
keysMethod · 0.65
toStringMethod · 0.65
replaceMethod · 0.45

Tested by

no test coverage detected