Saigesp / json-translate

Translate json files with DeepL or AWS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Variables in the target language

HenLab opened this issue · comments

commented

The script also sets variables in the target language, e.g. :number words -> then :nummer words. But the result should be :number wrote.

Hi @HenLab, thanks for the warning.

The way you define variables is quite specific to the environment/framework you use, so there is no simple common solution to solve this.

When I have some more time I will look for a solution. If you or anyone else finds one, you can make a PR and I will review it as soon as possible.

Best regards,

Some other tools have included it.
For example https://github.com/gmonarque/go-json-translate says

Supports variables in the translated text. For example, hello, {name} won't be translated to bonjour, {prénom} but to bonjour, {name} Available enclosure tags are: {}, #{} and []. It's very easy to add new ones.

https://github.com/leolabs/json-autotranslate?tab=readme-ov-file

Under available matchers they say

icu (default, matches ICU MessageFormat interpolations)
i18next (matches i18next interpolations)
sprintf (matches sprintf-style interpolations like %s)
none (doesn't match any interpolations)

Maybe just start with ICU