Skip to content

Instantly share code, notes, and snippets.

@rixx
Last active October 21, 2024 11:51
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
def defuzzy(message):
import pathlib, polib
pofiles = list(pathlib.Path(".").glob("pretalx/**/**/django.po"))
for path in pofiles:
po = polib.pofile(path)
entry = po.find(message)
if entry and entry.fuzzy:
entry.flags.remove("fuzzy")
entry.previous_msgid = None
po.save()
def rename_source_string(message, new_message):
pofiles = list(pathlib.Path(".").glob("pretalx/**/**/django.po"))
for path in pofiles:
po = polib.pofile(path)
entry = po.find(message)
if entry:
entry.msgid = new_message
po.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment