json-autotranslate
json-autotranslate copied to clipboard
i18next plurals
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?
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.
This could be a workaround. It's not ideal, though, since we have 15ish languages and this form is used only in a few
Yeah, that's a valid concern. Do you have an idea for how JSON Autotranslate could be improved to accomodate for this situation?
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?