typesafe-i18n icon indicating copy to clipboard operation
typesafe-i18n copied to clipboard

Feature request: exhaustive plural syntax

Open dilame opened this issue 2 years ago • 0 comments

Discussed in https://github.com/ivanhofer/typesafe-i18n/discussions/753

Originally posted by dilame December 18, 2023 In russian, we have 3 forms of plurals. And there is no way to describe it with typesafe-i18n.

const ruCardinalRules = new Intl.PluralRules("ru-RU");
ruCardinalRules.select(0) // many
ruCardinalRules.select(1) // one 
ruCardinalRules.select(2) // few 
ruCardinalRules.select(100) // many

We can describe it as 'one' | 'few' | 'many'.

None of overloads enumerated in docs fits russian usecase. The only way i found is use full syntax with random strings

'У меня есть {0} {{empty|яблоко|empty|яблока|яблок|empty}}'

I think we need some syntax to selectively describe only needed forms. It could look something like this

'У меня есть {0} {{one:яблоко|few:яблока|many:яблок}}'

dilame avatar Dec 18 '23 11:12 dilame