Skip to content

Conversation

@abhinavohri
Copy link
Contributor

This PR adds a field to make compact mode configurable for json files translated by weblate.
Fixes #14126

@abhinavohri abhinavohri requested a review from nijel as a code owner April 29, 2025 17:35
Copy link
Member

@nijel nijel left a 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?

@nijel nijel added this to the 5.12 milestone Apr 29, 2025
@abhinavohri
Copy link
Contributor Author

Looks good. Can you please also update the documentation and add a changelog entry?

Sure!

@abhinavohri abhinavohri requested a review from AliceVisek as a code owner April 30, 2025 14:40
.. 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
Copy link
Member

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.

Copy link
Contributor Author

@abhinavohri abhinavohri May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies, reverted it.

@nijel nijel self-assigned this May 5, 2025
nijel added a commit to nijel/weblate that referenced this pull request May 6, 2025
Noticed by @KasukabeDefenceForce in WeblateOrg#14733.
Co-authored-by: AliceVisek <alice@weblate.org>
@nijel nijel enabled auto-merge (squash) May 6, 2025 06:33
nijel added a commit that referenced this pull request May 6, 2025
Noticed by @KasukabeDefenceForce in #14733.
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 (", ", ": ")
Copy link
Member

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:

Suggested change
(",", ":") 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.

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"),
Copy link
Member

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:

Suggested change
label=gettext_lazy("Compact Mode"),
label=gettext_lazy("Avoid spaces after separators"),

Comment on lines 890 to 892
| ``use_compact_separators`` | Use compact separators in | ``true`` or ``false``|
| | JSON output (no space after | |
| | ``:`` and ``,``) | |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sync with ode changes:

Suggested change
| ``use_compact_separators`` | Use compact separators in | ``true`` or ``false``|
| | JSON output (no space after | |
| | ``:`` and ``,``) | |
| ``use_compact_separators`` | Avoid spaces after separators| |

@nijel nijel requested a review from AliceVisek May 6, 2025 08:29
auto-merge was automatically disabled May 7, 2025 17:12

Head branch was pushed to by a user without write access

@nijel nijel merged commit 1740ac8 into WeblateOrg:main May 12, 2025
48 of 49 checks passed
@nijel
Copy link
Member

nijel commented May 12, 2025

Merged, thanks for your contribution!

nijel added a commit that referenced this pull request May 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configurable Spacing After ":" in JSON via "Customize JSON Output" addon

3 participants