-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Configurable Spacing After ":" in JSON via "Customize JSON Output" addon #14733
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
Conversation
nijel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Can you please also update the documentation and add a changelog entry?
Sure! |
docs/changes/contributors/5.11.rst
Outdated
| .. only:: not gettext | ||
|
|
||
| Michal Čihař, Gersona, Kartik Ohri, Mehdi El Oualy, Yash Kumar, nijel, Viktor Khokhryakov, AliceVisek, KasukabeDefenceForce | ||
| Michal Čihař, Gersona, Kartik Ohri, Mehdi El Oualy, Yash Kumar, nijel, Viktor Khokhryakov, AliceVisek, Abhinav Ohri |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name is taken from Git commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, reverted it.
Noticed by @KasukabeDefenceForce in WeblateOrg#14733.
Co-authored-by: AliceVisek <alice@weblate.org>
Noticed by @KasukabeDefenceForce in #14733.
weblate/addons/json.py
Outdated
| store.store.dump_args["sort_keys"] = bool(int(config.get("sort_keys", 0))) | ||
| use_compact_separators = bool(int(config.get("use_compact_separators", 0))) | ||
| store.store.dump_args["separators"] = ( | ||
| (",", ":") if use_compact_separators else (", ", ": ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As indent is always turned on, this should be:
| (",", ":") if use_compact_separators else (", ", ": ") | |
| (",", ":" if use_compact_separators else ": ") |
See https://docs.python.org/3/library/json.html#json.dump
The tests I've added in #14795 reveal this.
weblate/addons/forms.py
Outdated
| class JSONCustomizeForm(BaseAddonForm): | ||
| sort_keys = forms.BooleanField(label=gettext_lazy("Sort JSON keys"), required=False) | ||
| use_compact_separators = forms.BooleanField( | ||
| label=gettext_lazy("Compact Mode"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to be more verbose here:
| label=gettext_lazy("Compact Mode"), | |
| label=gettext_lazy("Avoid spaces after separators"), |
docs/admin/addons.rst
Outdated
| | ``use_compact_separators`` | Use compact separators in | ``true`` or ``false``| | ||
| | | JSON output (no space after | | | ||
| | | ``:`` and ``,``) | | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sync with ode changes:
| | ``use_compact_separators`` | Use compact separators in | ``true`` or ``false``| | |
| | | JSON output (no space after | | | |
| | | ``:`` and ``,``) | | | |
| | ``use_compact_separators`` | Avoid spaces after separators| | |
Head branch was pushed to by a user without write access
|
Merged, thanks for your contribution! |
This PR adds a field to make compact mode configurable for json files translated by weblate.
Fixes #14126