From f636679a08c88cf7d8dc859b326c264cc6d4959e Mon Sep 17 00:00:00 2001 From: Tobias Schlatter Date: Fri, 12 Jul 2024 14:43:49 +0200 Subject: [PATCH] fix(formats): new_translation = "[]\n" for go-i18n-json The go-i18n-json v1 format uses an array as top level element (unlike all other JSON formats). I have manually checked, that the added `parse_file` line in the tests would have caught this. Discovered while working on #11133 / #11937. --- weblate/formats/tests/test_formats.py | 1 + weblate/formats/ttkit.py | 1 + 2 files changed, 2 insertions(+) diff --git a/weblate/formats/tests/test_formats.py b/weblate/formats/tests/test_formats.py index 9fb2fee40a5f..8f447d531931 100644 --- a/weblate/formats/tests/test_formats.py +++ b/weblate/formats/tests/test_formats.py @@ -548,6 +548,7 @@ class GoI18NV1JSONFormatTest(JSONFormatTest): MASK = "go-i18n-json/*.json" EXPECTED_PATH = "go-i18n-json/cs_CZ.json" FIND_CONTEXT = "hello" + MATCH = "[]\n" NEW_UNIT_MATCH = ( b'{\n "id": "key",\n "translation": "Source string"\n }\n' ) diff --git a/weblate/formats/ttkit.py b/weblate/formats/ttkit.py index 7c76ec68407a..8a5bee4c134f 100644 --- a/weblate/formats/ttkit.py +++ b/weblate/formats/ttkit.py @@ -1496,6 +1496,7 @@ class GoI18JSONFormat(JSONFormat): format_id = "go-i18n-json" loader = ("jsonl10n", "GoI18NJsonFile") autoload: tuple[str, ...] = () + new_translation = "[]\n" supports_plural: bool = True