python-docs-fr/.scripts/check-colon.py
2023-04-08 12:34:49 +00:00

21 lines
574 B
Python

import pathlib
from itertools import chain
import polib
def check(file):
pofile = polib.pofile(file)
for entry in pofile:
if not entry.msgstr:
continue
if entry.msgid.endswith(" ::"):
entry.msgstr = entry.msgstr.rstrip(": \u202f\u00A0") + " ::"
if entry.msgid.endswith("::") and not entry.msgid.endswith(" ::"):
entry.msgstr = entry.msgstr.rstrip(": ,. \u202f\u00A0") + "\u00A0::"
pofile.save()
for file in chain(pathlib.Path(".").glob("*.po"), pathlib.Path(".").glob("*/*.po")):
check(file)