next-intl selecting enum-based values not working

63 Views Asked by At

I needed next-intl translation for my next.js projenct (nextjs v13.4). Following official example on https://next-intl-docs.vercel.app/docs/usage/messages#selecting-enum-based-values

which stated

(in file en.json)

"message": "{gender, select, female {She} male {He} other {They}} is online."

and (in place of use)

t('message', {gender: 'female'});

It didn't work for some reason, not reading translation message well?

1

There are 1 best solutions below

0
On

Well it turned out that if I have another translation file, in my case

sr.json (Serbian)

equivalent values (for the same key) must be included in that file too, like in en.json file, there should be no difference in order for this to work in an language.

Like:

"message": "{gender, select, female {Она} male {Oн} other {Oни}} је на мрежи."