menu

LinguiJS

Community about internationalization of React and JavaScript apps using LinguiJS library

Channels
Team

How do you pass variables other than count to a Plural form?

September 17, 2019 at 6:07pm

How do you pass variables other than count to a Plural form?

September 17, 2019 at 6:07pm
I have this component, which generates an error: Invalid plural rule 'components'. Must be zero, one, two, few, many, other or exact number depending, so it obviously expects the value to be a number. But how, do I specify other values?
<Plural
value={{
count: likeCount,
first: i18n._(t('ui.you')`Você`),
second: likes[1]?.displayName,
third: likes[2]?.displayName,
otherCount: smartNumber(likeCount - 2),
}}
_1="<0>Você</0> gostou"
_2="<0>Você</0> e <0>{second}</0> gostavam"
_3="<0>Você</0>, <0>{second}</0> e <0>{third}</0> gostavam"
other="<0>Você</0>, <0>{second}</0> e {otherCount} outras gostavam"
components={[<BoldComponent />]}
/>
No messages yet