Fixes regex patter for verifying ICU plural syntax strings.

This commit is contained in:
mkarolin
2022-10-24 21:24:16 -04:00
parent 95d09a503d
commit 9f783023be
+8 -3
View File
@@ -262,9 +262,14 @@ def create_xtb_format_translationbundle_tag(lang):
def check_plural_string_formatting(grd_string_content, translation_content):
"""Checks 'plural' string formatting in translations"""
pattern = re.compile(
r"\s*{.*,\s*plural,(\s*offset:[0-2])?"
r"(\s*(=[0-2]|[zero|one|two|few|many])"
r"\s*{(.*)})+\s*other\s*{(.*)}\s*}\s*")
r"\s*{(.*,\s*plural,)(\s*offset:[0-2])?"
r"(\s*(=0|zero)\s*{(.*)})?"
r"(\s*(=1|one)\s*{(.*)})?"
r"(\s*(=2|two)\s*{(.*)})?"
r"(\s*(few)\s*{(.*)})?"
r"(\s*(many)\s*{(.*)})?"
r"(\s*other\s*{(.*)})?"
r"\s*}\s*")
if pattern.match(grd_string_content) is not None:
if pattern.match(translation_content) is None:
error = ('Translation of plural string:\n'