Rudra
Rudra

Reputation: 1688

I18nPluralPipe adding offset

I have a multiselect dropdown and I want to pluralize the text as mentioned below. I tried using I18nPluralPipe but not able to provide an offset of 1

ListItem = [Lion, Tiger, Cat, Fox]
Select 1 Item(Tiger) = "Tiger", 
Select 3 Item(Tiger, Cat, Fox) = "Tiger +3 Other"

"Tiger +3 Others" is wrong, instead I want "Tiger +2 Others" and that's where I need the offset.

You can try I18nPluralPipe in this example

Upvotes: 1

Views: 438

Answers (1)

Paul
Paul

Reputation: 2076

Just substract 1 from the length. In that way you get the correct number:

  <span *ngIf="toppings.value?.length > 1" class="example-additional-selection">
    (+{{ toppings.value.length - 1 | i18nPlural: messageMapping }})
  </span>

Upvotes: 2

Related Questions