Skip to content

I18n plural forms #678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 25, 2023
Merged

Conversation

bmoczulski
Copy link
Contributor

While working on Polish translations I noticed that some labels can't be translated correctly due lack of plural forms. In Polish there are two plural forms of nouns - one for cadrinality 2-4 mod 10 (except 12-14) and the another for everything else > 1. Other languages have different rules for plurals, sometimes even more complex. Considering that both react-i18next and Weblate fully support translation of plural forms I propose to change the affected entries by adding {count: n} to relevant t() calls and _one/_other suffix for English translation. This will make both systems aware of plurality of these labels. Weblate will show a form with all required plural variants in a given language and react-i18next will look for appropriate suffixes based on count and language.

This is my firs PR here so let me take the opportunity to congratulate you on creating this awesome utility. I'm currently evaluating ntfy in my monitoring deployment and I have to admit I'm impressed by the plethora of features and comprehensive documentation. Well done! The very least I can do in return is to provide some translations in my mother tongue.

In many languages there is more than one plural form of nouns and rules
for choosing the correct one are often far more complex than in English.
Luckily both react-i18next and Weblate provide built-in support for
translating and selecting plural forms in accordance with grammatical
rules of any given language.

In order to enable plural forms `{count: n}` option is added to relevant
`t()` calls. In translations files "_one" and "_other" suffix is added
to English labels such that Weblate can detect which entries represent a
set of plural forms and show appropriate language-specific form on the
translation page. E.g. in Polish there are 2 plural forms and hence 3
resulting suffixes: "_one", "_few", "_many".

Note on transition period: in the absence of expected suffixed variants
react-i18next will use non-suffixed one (if present) so existing
translations will continue to work just fine even if they happen to be
grammatically imperfect. Translators can provide proper plural forms in
once this change is merged and Weblate will then replace non-suffixed
labels with the suffixed ones.
…s, messages

Following up on the previous commit this one introduces Polish
translations for plural forms of reservations. emails, messages in
upgrade modal.
@binwiederhier binwiederhier merged commit 8cc2311 into binwiederhier:main Mar 25, 2023
@binwiederhier
Copy link
Owner

Thank you. Fixed the other languages too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants