Open marselmustafin opened 5 months ago
I do not think there is any such behaviour available today. It will only translate the missing keys. Do you think any translation API supports something like this? E.g. returning all the needed pluralisation keys based on one key?
@davidwessman no, I never faced with such ready-made API. We have been using Lokalise for a long time and they provided us with these keys, but afaik they use real people for that.
In i18n-tasks
project there's a plural
mode exists for missing
task which shows all missed plural keys for non-en locales like ar
, ru
, etc. But translate-missing
provides only 1-to-1 keys translation. Even adding of few
/many
keys to en didn't help because the translation engine google
/openai
is not aware of context of the number and it gives wrong translation.
I think it would be awesome to upgrade translate-missing
task to add translations for plurals as well. As an idea we could pass some number related to the key like few
: 2, many
: 5 to the translation request and then replace it with %{count}
again.
Yes, that would be interesting to try out. Send translate for multiple plural-keys and see if they are different
Seems like it would be pretty complex rules to set this up: https://guides.rubyonrails.org/i18n.html#locale-specific-rules https://cldr.unicode.org/index/cldr-spec/plural-rules https://www.unicode.org/cldr/charts/45/supplemental/language_plural_rules.html
This is something we'd gain from. We currently use Phrase for managing our strings because this is something they support quite well (and a lot of the other "Rails compatible" translation SaaS don't) but the relative cost is high considering we don't use 90% of their other features.
Ok I think I have this "working" at least as a proof of concept.
As per the comments above, it's a little tricky and assumptions have to be made - as a result it probably only works well from en
to other languages because I took the approach of using the other
key to fill in the missing keys so it would work well with translations. Ultimately, if you're just looking to get the missing keys, that's a lot easier.
I pushed our large application using it through the OpenAI translator and it did a pretty good job at ensuring the correct keys were translated.
I'll push up a branch, there were a bunch of other changes that I made along the way so I'll try and split it up nicely.
I have such keys in my base
en
locale:When I translate it to other languages with
translate-missing
I have the same keys everywhere. E.g. in Russian:But I would like to have more values included in locales that require more pluralization keys, expected result for Russian:
Is it possible to achieve this result currently? Or it requires additional feature implementation?