From 35f7d17c3e566b2480411f88e5d60dd916e7f926 Mon Sep 17 00:00:00 2001 From: Anthony Chen <31290848+slightlyskepticalpotat@users.noreply.github.com> Date: Sun, 25 Feb 2024 11:17:05 -0500 Subject: [PATCH] add numerus format check to check-translations.py (translation linter) Cherry-picked from: b4d92e10 Github Pull Request: #3446 --- contrib/devtools/check-translations.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/contrib/devtools/check-translations.py b/contrib/devtools/check-translations.py index 8ba01cd76..00dc1e11c 100755 --- a/contrib/devtools/check-translations.py +++ b/contrib/devtools/check-translations.py @@ -130,9 +130,23 @@ def check_all_translations(): # pick all numerusforms if numerus: translations = [i.text for i in translation_node.findall('numerusform')] + if len(translations) == 0: + print(f'Numerus message without numerusform translations, needs fix.', sanitize_string(source)) + have_errors = True + if translation_node.text is not None and not translation_node.text.isspace(): + print(f'Numerus message contains extra text {translation_node.text}, needs fix.') + have_errors = True + for child in list(translation_node.iter())[1:]: # exclude root + if child.tag != 'numerusform': + print('Numerus message contains extra child node, needs fix.', sanitize_string(source)) + have_errors = True + break else: translations = [translation_node.text] - + if len(list(translation_node.iter())) != 1: + print('Non-numerus message contains child node in translation, needs fix.', sanitize_string(source)) + have_errors = True + for translation in translations: if translation is None: continue