import polib
import pathlib
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 pathlib.Path(".").glob("*.po"):
check(file)
for file in pathlib.Path(".").glob("*/*.po"):
check(file)
See http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#literal-blocks
> As a convenience, the "::" is recognized at the end of any paragraph. If immediately preceded by whitespace, both colons will be removed from the output (this is the "partially minimized" form). When text immediately precedes the "::", one colon will be removed from the output, leaving only one colon visible (i.e., "::" will be replaced by ":"; this is the "fully minimized" form).