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

JSON file: Adding a new translation string it is stored in the nested JSON format #4779

Closed
KarinBerg opened this issue Oct 29, 2020 · 8 comments · Fixed by translate/translate#4161
Assignees
Labels
bug Something is broken. translate-toolkit Issues which need to be fixed in the translate-toolkit

Comments

@KarinBerg
Copy link

Describe the bug
I observe a behaviour change between version 3.1.1 to 4.1.1 or 4.3.1.

I updated the Weblate docker container from version 3.1.1-6 via 4.1.1-3 to latest version 4.3.1-1.
I have a component with "file format" = "JSON file"

Before the update I had the following behaviour:
When I add a new translation key like "a.b.c" to the default language (English) via Weblate UI it is stored as

"a.b.c": "dd"

After the update I had the following behaviour:
When I add a new translation key like "a.b.c" to the default language (English) via Weblate UI it is stored as

"a": {
        "b": {
            "c": "dd"
        }
    }

Is this a bug?

To reproduce the bug

Steps to reproduce the behaviour:

  1. Create a component with "file format" = JSON file
  2. Within Weblate go to the default language of the component (not sure if the languages matters)
  3. Add a new translation string via "Tools" -> "Add new translation string"
  4. Add as "Translation key" a.b.c
  5. Click on button "Add"
  6. Then choose "Files"->"Download original translation file (JSON file)"
  7. Open download file in text editor

Expected behavior
If the file format of the translation file is chosen as "JSON file" than I expect that the nested file format is not used.

Server configuration and status

 * Weblate: 4.3.1
 * Django: 3.1.2
 * siphashc: 2.1
 * Whoosh: 2.7.4
 * translate-toolkit: 3.1.1
 * lxml: 4.6.1
 * Pillow: 8.0.0
 * bleach: 3.2.1
 * python-dateutil: 2.8.1
 * social-auth-core: 3.3.3
 * social-auth-app-django: 4.0.0
 * django-crispy-forms: 1.9.2
 * oauthlib: 3.1.0
 * django-compressor: 2.4
 * djangorestframework: 3.12.1
 * django-filter: 2.4.0
 * django-appconf: 1.0.4
 * user-agents: 2.2.0
 * filelock: 3.0.12
 * setuptools: 40.8.0
 * jellyfish: 0.8.2
 * openpyxl: 3.0.5
 * celery: 4.4.7
 * kombu: 4.6.11
 * translation-finder: 2.4
 * weblate-language-data: 2020.10
 * html2text: 2020.1.16
 * pycairo: 1.16.2
 * pygobject: 3.30.4
 * diff-match-patch: 20200713
 * requests: 2.24.0
 * django-redis: 4.12.1
 * hiredis: 1.1.0
 * sentry_sdk: 0.19.1
 * Cython: 0.29.21
 * misaka: 2.1.1
 * GitPython: 3.1.9
 * borgbackup: 1.1.14
 * pyparsing: 2.4.7
 * Python: 3.7.3
 * Git: 2.20.1
 * psycopg2: 2.8.6
 * psycopg2-binary: 2.8.6
 * phply: 1.2.5
 * chardet: 3.0.4
 * ruamel.yaml: 0.16.12
 * tesserocr: 2.5.1
 * akismet: 1.1
 * boto3: 1.16.1
 * zeep: 4.0.0
 * aeidon: 1.7.0
 * iniparse: 0.5
 * mysqlclient: 2.0.1
 * Mercurial: 5.5.2
 * git-svn: 2.20.1
 * git-review: 1.28.0
 * Redis server: 5.0.8
 * PostgreSQL server: 10.11
 * Database backends: django.db.backends.postgresql
 * Cache backends: default:RedisCache, avatar:FileBasedCache
 * Email setup: django.core.mail.backends.smtp.EmailBackend: rex10.flatbooster.com
 * OS encoding: filesystem=utf-8, default=utf-8
 * Celery: redis://weblate-redis-master:6379/1, redis://weblate-redis-master:6379/1, regular
 * Platform: Linux 5.4.0-1031-azure (x86_64)

Weblate deploy checks

SystemCheckError: System check identified some issues:

CRITICALS:
?: (weblate.E027) The path /app/data/settings-override.py is owned by different user, check your DATA_DIR settings.
        HINT: https://docs.weblate.org/en/weblate-4.3.1/admin/install.html#file-permissions

System check identified 1 issue (2 silenced).
@nijel nijel self-assigned this Oct 29, 2020
@nijel nijel added bug Something is broken. translate-toolkit Issues which need to be fixed in the translate-toolkit labels Oct 29, 2020
@github-actions
Copy link

The issue you've reported needs to be addressed in the translate-toolkit. Please file the issue there, and include links to any relevant specifications about the formats (if applicable).

@nijel
Copy link
Member

nijel commented Oct 29, 2020

This should be fixed by translate/translate#4161

nijel added a commit to translate/translate that referenced this issue Oct 30, 2020
This is a regression introduced by #4091 as that makes the flat JSON
file expand the unit keys.

Fixes WeblateOrg/weblate#4779
@github-actions
Copy link

Thank you for your report, the issue you have reported has just been fixed.

  • In case you see a problem with the fix, please comment on this issue.
  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

@KarinBerg
Copy link
Author

Is there a way to get this bugfix of the translate tool? Or do I have to wait for a new Docker image?

@nijel
Copy link
Member

nijel commented Nov 2, 2020

It should be already present in the bleeding tag. It uses translate-toolkit from the master branch.

@KarinBerg
Copy link
Author

Thanks 👍
I tested with weblate/weblate:bleeding-2020-11-02-00c4a1e6ac58694e31a2571ec42c6ef6c62ace5c and it works well.
Can confirm the bugfix.

@carpiediem
Copy link

I'm seeing the same (or a similar issue on v4.12.1). Should I file a new issue? Or am I missing a configuration option?

When I added two new translations to my component (which already has a flat JSON file in the translated language), they were added at the end in a nested format.

{
 "a.b.c": "ABC",
  "d.e.f": "DEF,
  "h": { "i": { "j": "HIJ" } },
  "k": { "l": { "m": "KLM" } }
}

@nijel
Copy link
Member

nijel commented Jun 6, 2022

In case you are using "JSON nested structure file", this is expected behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken. translate-toolkit Issues which need to be fixed in the translate-toolkit
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants