Skip to content

Commit

Permalink
check_po: fix badly formatted flags
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Noël Avila <jn.avila@free.fr>
  • Loading branch information
jnavila committed Mar 9, 2024
1 parent 8aaa1c8 commit 45ec1c3
Show file tree
Hide file tree
Showing 25 changed files with 92,179 additions and 92,187 deletions.
7,078 changes: 3,539 additions & 3,539 deletions po/documentation.de.po

Large diffs are not rendered by default.

8,152 changes: 4,076 additions & 4,076 deletions po/documentation.es.po

Large diffs are not rendered by default.

8,208 changes: 4,104 additions & 4,104 deletions po/documentation.es_MX.po

Large diffs are not rendered by default.

8,086 changes: 4,043 additions & 4,043 deletions po/documentation.fr.po

Large diffs are not rendered by default.

8,172 changes: 4,086 additions & 4,086 deletions po/documentation.hu.po

Large diffs are not rendered by default.

7,150 changes: 3,575 additions & 3,575 deletions po/documentation.id.po

Large diffs are not rendered by default.

5,812 changes: 2,906 additions & 2,906 deletions po/documentation.is.po

Large diffs are not rendered by default.

8,640 changes: 4,320 additions & 4,320 deletions po/documentation.it.po

Large diffs are not rendered by default.

8,898 changes: 4,449 additions & 4,449 deletions po/documentation.ja.po

Large diffs are not rendered by default.

7,790 changes: 3,895 additions & 3,895 deletions po/documentation.ko.po

Large diffs are not rendered by default.

9,742 changes: 4,871 additions & 4,871 deletions po/documentation.mr.po

Large diffs are not rendered by default.

4,680 changes: 2,340 additions & 2,340 deletions po/documentation.nb_NO.po

Large diffs are not rendered by default.

5,902 changes: 2,951 additions & 2,951 deletions po/documentation.nl.po

Large diffs are not rendered by default.

7,106 changes: 3,553 additions & 3,553 deletions po/documentation.pl.po

Large diffs are not rendered by default.

7,762 changes: 3,881 additions & 3,881 deletions po/documentation.pt_BR.po

Large diffs are not rendered by default.

7,670 changes: 3,835 additions & 3,835 deletions po/documentation.pt_PT.po

Large diffs are not rendered by default.

6,078 changes: 3,039 additions & 3,039 deletions po/documentation.ro.po

Large diffs are not rendered by default.

8,866 changes: 4,433 additions & 4,433 deletions po/documentation.ru.po

Large diffs are not rendered by default.

4,318 changes: 2,159 additions & 2,159 deletions po/documentation.sk.po

Large diffs are not rendered by default.

7,810 changes: 3,905 additions & 3,905 deletions po/documentation.tr.po

Large diffs are not rendered by default.

9,328 changes: 4,664 additions & 4,664 deletions po/documentation.uk.po

Large diffs are not rendered by default.

7,858 changes: 3,929 additions & 3,929 deletions po/documentation.vi.po

Large diffs are not rendered by default.

10,134 changes: 5,067 additions & 5,067 deletions po/documentation.zh_HANS-CN.po

Large diffs are not rendered by default.

9,096 changes: 4,548 additions & 4,548 deletions po/documentation.zh_HANT.po

Large diffs are not rendered by default.

30 changes: 11 additions & 19 deletions scripts/check_po
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,27 @@ def main(filename: str, modify: bool = False):
translated with the same fixed strings'''

po = polib.pofile(filename, wrapwidth=0)
file_modified = False
for entry in po:
flags = set(entry.flags)
flags_modified= False
if entry.msgstr != "" and not entry.obsolete and not entry.fuzzy:
for matched in LINKGIT_REGEX.finditer(entry.msgid):
g = matched.group(0)
if not FALSE_POSITIVES.findall(g) and matched.group(0) not in entry.msgstr:
print(f"ERROR {filename}: {entry.msgid}, {entry.msgstr}:\n {matched.group(0)} not found in translation")
if entry.tcomment != "":
entry.tcomment += "\n"
entry.tcomment += f"ERROR: {matched.group(0)} not found in translation"
flags.add("fuzzy")
flags_modified = True
placeholders = []
for matched in LINKGIT_REGEX.finditer(entry.msgid):
g = matched.group(0)
# if the string is present, tag it as a placeholder for weblate
if not FALSE_POSITIVES.findall(g):
placeholders.append(g)
if entry.msgstr != "" and not entry.obsolete and not entry.fuzzy and matched.group(0) not in entry.msgstr:
print(f"ERROR {filename}: {entry.msgid}, {entry.msgstr}:\n {matched.group(0)} not found in translation")
if entry.tcomment != "":
entry.tcomment += "\n"
entry.tcomment += f"ERROR: {matched.group(0)} not found in translation"
flags.add("fuzzy")
flags = {x for x in flags if x.startswith("priority") or x in ["fuzzy", "no-wrap", "ignore-same", "ignore-ellipsis"]}
if len(placeholders) > 0:
flags_modified = True
flags = {x for x in flags if not x.startswith("placeholders:")}
flags.add("placeholders:'" + "':'".join(placeholders) + "'")

if flags_modified:
file_modified = True
entry.flags = list(flags)
if file_modified and modify:
flags = list(flags)
flags.sort()
entry.flags = flags
if modify:
po.save(filename)


Expand Down

0 comments on commit 45ec1c3

Please sign in to comment.