Skip to content

Instantly share code, notes, and snippets.

@rixx
Created May 2, 2024 19:09
Show Gist options
  • Save rixx/9f5e93d8d286f683f0b7efc7edd82961 to your computer and use it in GitHub Desktop.
Save rixx/9f5e93d8d286f683f0b7efc7edd82961 to your computer and use it in GitHub Desktop.
polib example for gnu gettext pofile editing
import pathlib, polib
pofiles = list(pathlib.Path(".").glob("**/**/django.po"))
defuzzy = ["foo", "bar"]
for path in pofiles:
po = polib.pofile(path)
for msg in defuzzy:
entry = po.find(msg)
if entry and entry.fuzzy:
entry.flags.remove("fuzzy")
entry.previous_msgid = None
po.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment