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

i18next plurals #57

Open
zeljkocurcic opened this issue Jan 25, 2022 · 4 comments
Open

i18next plurals #57

zeljkocurcic opened this issue Jan 25, 2022 · 4 comments
Assignees

Comments

@zeljkocurcic
Copy link

Hi @leolabs, first, thank you for this wonderful library, it is really useful for projects that are translated into multiple languages. We are using plurals in our i18next project, something like this:

English:

    "Show older comments_one": "Show {{count}} older comment",
    "Show older comments_other": "Show {{count}} older comments",

Polish:

    "Show older comments_one": "Pokaż {{count}} starszy komentarz",
    "Show older comments_few": "Pokaż {{count}} starsze komentarze",
    "Show older comments_many": "Pokaż {{count}} starszych komentarzy",

As you can see, Polish has different plural forms. When I ran json-autotranslate with -d, it removed all these and added the key with _other as the last entry under the parent key. Is there a way to do it correctly for languages like this or this is something that's not implemented?

@leolabs
Copy link
Owner

leolabs commented Jan 28, 2022

Hmm, that's a good question. JSON Autotranslate doesn't have any specific behavior when it comes to plurals. Adding the "_few" and "_many" keys to the English source file could work, although I guess it adds a bit of redundant content since these aren't actually needed in English.

@leolabs leolabs self-assigned this Jan 28, 2022
@zeljkocurcic
Copy link
Author

This could be a workaround. It's not ideal, though, since we have 15ish languages and this form is used only in a few

@leolabs
Copy link
Owner

leolabs commented Jan 31, 2022

Yeah, that's a valid concern. Do you have an idea for how JSON Autotranslate could be improved to accomodate for this situation?

@zeljkocurcic
Copy link
Author

I haven't actually looked at the code, but I guess we could use i18next's plural resolver when we see a key has plural forms in the default language: https://github.com/i18next/i18next/blob/master/src/PluralResolver.js

But what to do with other translation engines supported by json-autotranslate?

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

2 participants