Last active
October 21, 2024 11:51
-
-
Save rixx/9f5e93d8d286f683f0b7efc7edd82961 to your computer and use it in GitHub Desktop.
polib example for gnu gettext pofile editing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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