This is the archived documentation for Angular v5. Please visit angular.io to see documentation for the current version of Angular.

I18nPluralPipe

npm Package @angular/common
Module import { I18nPluralPipe } from '@angular/common';
Source common/src/pipes/i18n_plural_pipe.ts
NgModule CommonModule

Maps a value to a string that pluralizes the value according to locale rules.

How To Use

expression | i18nPlural:mapping[:locale]

Description

Where:

      
      @Component({
  selector: 'i18n-plural-pipe',
  template: `<div>{{ messages.length | i18nPlural: messageMapping }}</div>`
})
export class I18nPluralPipeComponent {
  messages: any[] = ['Message 1'];
  messageMapping:
      {[k: string]: string} = {'=0': 'No messages.', '=1': 'One message.', 'other': '# messages.'};
}