ci(validate): warn on segmented keys in the json, ex: aaaa.bbbb.cccc

This commit is contained in:
Lemmy
2026-07-19 00:16:13 -04:00
parent b5ffdcf6d4
commit 7a476bf7b3
2 changed files with 35 additions and 8 deletions
@@ -148,6 +148,17 @@ class TranslationKeyTests(unittest.TestCase):
with self.subTest(key=key):
self.assertFalse(validate_plugins.is_valid_translation_key(key))
def test_rejects_dotted_json_object_keys(self) -> None:
# A flat dotted key is what the i18n platform expands into nested objects; the JSON
# source must nest instead, so an object key with a dot is invalid.
self.assertFalse(validate_plugins.is_valid_key_segment("settings.label"))
self.assertTrue(validate_plugins.is_valid_key_segment("eyecare-active-duration"))
translations = {"settings.eyecare-active-duration.label": "Active Duration"}
self.assertEqual(
validate_plugins.invalid_translation_keys(translations),
["settings.eyecare-active-duration.label"],
)
def test_walks_nested_keys_and_reports_full_paths(self) -> None:
translations = {
"settings": {