Skip to content

Commit 6f07e31

Browse files
committed
Add ignore words
1 parent 098d61d commit 6f07e31

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

scripts/check_langs_in_po.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
"""
33
Check .po files for presence of specific language patterns in translated strings.
4-
Languages currently checked: Russian, Polish, Ukranian.
4+
Languages currently checked: Russian, Polish, Ukrainian.
55
"""
66
import argparse
77
import re
@@ -13,6 +13,25 @@
1313
POLISH = r"ĄĆĘŁŃŚŹŻąćęłńśźż"
1414
UKRAINIAN = r"ҐЄІЇґєії"
1515

16+
# Words to ignore if found in msgstr
17+
IGNORE_WORDS = [
18+
"Charles-François",
19+
"Gruszczyński",
20+
"Jędrzejewski-Szmek",
21+
"Kołodziej",
22+
"Коренберг Марк",
23+
"Łukasz",
24+
"Łapkiewicz",
25+
"Марк Коренберг",
26+
"Michał",
27+
"Ożarowski",
28+
"Sławecki",
29+
"Stanisław",
30+
"Tvrtković",
31+
"Wołodźko",
32+
"Є",
33+
]
34+
1635

1736
def build_pattern(enable_russian=True, enable_polish=True, enable_ukrainian=True):
1837
"""
@@ -30,10 +49,20 @@ def build_pattern(enable_russian=True, enable_polish=True, enable_ukrainian=True
3049
return re.compile(f"[{''.join(parts)}]")
3150

3251

52+
def should_ignore(text):
53+
"""
54+
Return True if the text contains any of the ignore words.
55+
"""
56+
for word in IGNORE_WORDS:
57+
if word in text:
58+
return True
59+
return False
60+
61+
3362
def find_matches_in_po(po_path, pattern):
3463
"""
3564
Search for matches in translated strings of a PO file.
36-
Skips entries with empty translations.
65+
Skips entries with empty translations or containing ignored words.
3766
"""
3867
matches = []
3968
if not pattern:
@@ -45,6 +74,9 @@ def find_matches_in_po(po_path, pattern):
4574
if not entry.msgstr.strip():
4675
continue
4776

77+
if should_ignore(entry.msgstr):
78+
continue
79+
4880
texts = [entry.msgstr]
4981

5082
for text in texts:

0 commit comments

Comments
 (0)