-
-
Notifications
You must be signed in to change notification settings - Fork 958
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
JSON format breaks i18next files due to automatic restructuring [$120 awarded] #775
Comments
Indeed these files are not properly supported by translate-toolkit so far. There already is issue #650 on same topic, but given that the file mentioned there no longer exists, I will close it in favour of this issue. |
Is there some way I can help to improve support for that format? |
Improving translate-toolkit support. Currently JsonFile._extract_translatables is able to load these, but the JsonFile.str method used for serialization does not recognize these specially formatted keys. So saves them as they are without parsing. |
Just for completeness: The old ticket #650 also included another issue, since Chrome web store localization files include fields that are not supposed to be translated (the |
Indeed, these are different problems, just happen to be based on same file format. |
I have a bit similar use case. Each key of parent structure is used as prefix for inner structures, "shop_" : {
"type_" : {
"int_set" : "Integer set", effectively results in key "shop_type_int_set" : "Integer set". |
@nijel any news on this? Do you need some help? |
@nijel i just debugged |
It can parse them, but it will write them differently (see first comment in this issue). See https://github.com/translate/translate/blob/master/translate/storage/jsonl10n.py#L157 |
Ok, after a lot of discussions i stopped working on |
Shipping that with Weblate is certainly okay. |
here's a gist how to fix this with a pre-commit hook: https://gist.github.com/saily/f8a9f72c6b064d51f09040d66e981240 |
Thanks to Daniel Widerin. Issue #775 Signed-off-by: Michal Čihař <michal@cihar.com>
Thanks, I've included the above script in examples. |
@nijel what kind of bounty would you want to have to get this added natively to weblate (either through translate-toolkit or directly - as a user I don't care how it is implemented)? |
@wichert we could just ship the script with weblate by default. |
That does not work, since the pre-commit hook is global and would break badly if you also use other formats. You would need a flag per repository that indicates if that hook needs to be run, so more integration is necessary as far as I can see. |
I think that adding support for this to translate-toolkit (and then Weblate) should be quite easy, I just haven't found time to do that (there are always more important things to do). Having similar bounty as on the WebExtension JSON format (#1380) would probably make me look into both of them rather sooner than later though ;-). |
@nijel I added a $120 bounty. |
@denim2x Did you really start working on this? I noticed you claimed the bounty with a completion date of last Monday, but I don't see any activity on your github account indicating you did anything. |
Unless there will be some progress here, I can look at this last week in June. |
Support for translate-toolkit has been submitted for review: translate/translate#3662 |
See WeblateOrg/weblate#775 Signed-off-by: Michal Čihař <michal@cihar.com>
New JSON variant added. Issue #775 Signed-off-by: Michal Čihař <michal@cihar.com>
I just had an interesting experience: I configured Weblate to manage translations for an Aurelia project, which uses i18next to handle translations. This worked wonderfully well, until I started testing with updated translations and found that half the translations had stopped working.
The problem turned out to be due to handling JSON structure: Weblate (via Translate Toolkit I guess?) always uses a flat structure for the data. So where my translation.json used to look like this:
it got transformed into this:
This breaks the translation lookup.
The text was updated successfully, but these errors were encountered: