-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Nested JSON format serializing None as "None" instead of null #9963
Comments
I think it always behaved this way. Anything in the json file is converted to a string, which is presented in weblate for translation. Until you touch these in weblate, they might be preserved, though. |
The partially translated French file in the screenshot was fully created and managed by Weblate 4.18.2. This diff is from a commit right after we upgraded to 5.0.1 (also then 5.0.2) I've confirmed with a quick local install that this is indeed how the format behaved in 4.18.2: https://gitlab.com/vinceh121/test9963/-/commit/75ea7019d80d8d170852031385beb50dcb1c56c6 Edit: this "None" behaviour in 5.0.2 seems to only apply when manually committing with the UI, and scheduled commits/push use null |
After further research and debugging, I've traced this change down to this commit in translate, originally for handling JSON numbers: translate/translate@d8d5a3e Perhaps it may make sense to add a special case for None? |
Both translate-toolkit and Weblate expect strings as translatable content. Right now, it converts any value to a string. Before translate/translate@d8d5a3e it would fail to load such file with ValueError. |
I understand that, but serializing a Python specific value into a generic JSON strikes me as odd. But then again, I've again confirmed that this behaviour is inconsistent as it only happens with manual commits, and scheduled commits do the padding with null in 5.0.2. Examples here, with scheduled commit: Nadekooo/YTTDFR@3ffa088 |
The problem seems in preserving null values once they are present. The first commit adds them as placeholders for missing values. translate/translate#5034 should address this. |
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). |
Thank you for your report; the issue you have reported has just been fixed.
|
Describe the issue
In between the upgrade between 4.18.2 and 5.0.1, a bug (or an undocumented change?) was introduced that makes the nested JSON format serialize Python None as the string "None" instead of the JSON null as padding within arrays.
I'm unclear on whether this is a bug in Weblate or in the Translate library.
I already tried
Steps to reproduce the behavior
Expected behavior
The padding within arrays should be done using nulls and not "None" strings.
Or this behaviour might be configurable, as I can see why some apps wouldn't play nice with nulls and may prefer a default string.
Screenshots
Exception traceback
No response
How do you run Weblate?
PyPI module
Weblate versions
Weblate deploy checks
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: