Import
import { WrPlural } from 'ngwr/pipes';
@Component({ imports: [WrPlural] })
export class MyComponent { /* ... */ }Live demo
Drag the count — English two-form vs Russian three-form.
Usage
{{ 1 | wrPlural: { one: 'comment', other: 'comments' } }}
<!-- "1 comment" -->
{{ 5 | wrPlural: { one: 'файл', few: 'файла', other: 'файлов' } : { locale: 'ru' } }}
<!-- "5 файлов" -->
{{ count() | wrPlural: forms : { includeValue: false } }}
<!-- word only -->Why ngwr provides this
Hand-rolled n % 10 pluralization breaks the moment a second language shows up, and Angular's i18n-plural requires the full i18n extraction pipeline. This pipe defers to Intl.PluralRules — correct for every CLDR locale, zero setup, works with plain strings from any source.
API
| Name | Description | Type | Default |
|---|---|---|---|
wrPlural | Picks the word form for a count via Intl.PluralRules. Forms are keyed by CLDR category (zero/one/two/few/many/other); missing keys fall back to other. | (value: number | null | undefined, forms: WrPluralForms, options: WrPluralOptions = {}) => string | — |
options.includeValue | Prefix the locale-formatted count before the word. | boolean | true |
options.locale | Locale override; defaults to Angular's LOCALE_ID. | string | LOCALE_ID |