-
Notifications
You must be signed in to change notification settings - Fork 17
Description
I'm not sure this is a bug or a feature.
The problem
I have the following English and Polish pluralized strings (using svelte-intl-precompile to transform them):
- en:
"{numYears, plural, one {1 year or less} other {# years}}"
- pl:
"{numYears, plural, one {1 rok lub mniej} other {# lat}}"
They both compile to the same JS options, e.g. for Polish:
{
o: "1 rok lub mniej",
h: `${numYears} lat`
}
However, numbers like 2, 3 and 4 will print the empty string for Polish but not for English, Danish or German.
Debugging the problem
After some head-scratching, I found that the problem is due to different Intl Plural rules for Polish that evaluate 2-4 to "few" instead of "other" and thus the "other" clause is not used here:
precompile-intl-runtime/src/index.ts
Line 58 in 83c7d0e
return key === 'other' ? 'h' : key[0]; |
What did I expect
I expected I could use the same translation strings for different locales -- not that I would have to take pluralization rules into account.
Is there a workaround
Yes, specifically for e.g. Polish, I can add a "few" clause which is identical to the "other" clause: "{numYears, plural, one {1 rok lub mniej} few {# lat} other {# lat}}"
Thanks for a great project.