Skip to content
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

i18n: Add support for plural forms #2660

Open
naglis opened this issue Nov 15, 2024 · 0 comments
Open

i18n: Add support for plural forms #2660

naglis opened this issue Nov 15, 2024 · 0 comments

Comments

@naglis
Copy link
Contributor

naglis commented Nov 15, 2024

i18next, the library used by Thorium for translations, supports plurals, but it is currently not used in Thorium.

I think it would be nice to display the correctly pluralized strings instead of appending all the possible variations at the end (e.g. 42 match(es)).

IIUC, there are a few strings that would benefit from plurals in Thorium:

I have experimented with adding support for it (i18next JSON v3, v4), it seems to work nicely. Please note that in order for i18next to apply plurals, the number placeholder must be named count.

There are some issues/unanswered questions:

  • Not sure which i18next JSON version to use. I have found v4 plural suffixes a bit easier to understand (here is a JSFiddle which displays the plural suffixes for a given language/i18next JSON version). It might also make sense to bite the bullet and switch to v4 before adding plurals so as not to have to migrate the keys afterwards. I am not sure if there are any issues (unrelated to plurals) from switching from v3 -> v4, though.
  • i18next-json-sync (the CLI tool to extract translatable strings) does not support plural keys (it simply removes them), although there are alternatives, e.g. https://github.com/felixmosh/i18next-locales-sync.
  • How would GitLocalize handle plural translations? Different languages may have different plural forms, so the key suffixes might also differ, e.g. in i18next JSON v4 the en keys would be: foo_one and foo_other, the lt (Lithuanian) keys would be foo_one, foo_few, foo_other. How would GitLocalize handle the foo_few key (what would it display as the "source" value?) when translating en -> lt?
  • IIUC, GitLocalize does not support adding new strings manually, so in order to add missing plural forms, it would have to be done via PR?
  • ...?
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

No branches or pull requests

1 participant