ivanhofer / typesafe-i18n

A fully type-safe and lightweight internationalization library for all your TypeScript and JavaScript projects.
https://github.com/ivanhofer/typesafe-i18n
MIT License
2.26k stars 78 forks source link

Plural rules not working properly with specific numbers. #734

Open bwprado opened 1 year ago

bwprado commented 1 year ago

Version

5.26.1

Describe the bug

When using typesafe-i18n with React.js and importing LL class for text translations for itens with plural rules, some numbers above 0 are not recognized as plural, for example:

<LineLabel> {LL.fit.programsPage.item.numberOfWorkouts(workoutsLength as number)} </LineLabel>

numberOfWorkouts: '{{ No workouts | 1 workout | ?? workouts }}',

This should return No workouts for 0 workoutsLength, 1 workout for 1 workoutsLength and any other number above 2 should return number workouts.

And it does for a variaty of numbers, but every number that ends with 1 or 2 (above 20) is either 1 workout or workouts (without the number)

Reproduction

React component:

const workouts = 21
return (
      <div>
            {LL.numberOfWorkouts(workouts)}
      </div>
)

Translation:

numberOfWorkouts: '{{ No workouts | 1 workout | ?? workouts }}',

Logs

There are no logs.

Config

{
   "baseLocale": "br",
   "adapter": "react",
   "$schema": "https://unpkg.com/typesafe-i18n@5.24.3/schema/typesafe-i18n.json"
}

Additional information

No response

ivanhofer commented 1 year ago

Can you please share a repo where I can reproduce this?