Tool to synchronize gettext .po files contents across anything (directories, git branches, …).
Find a file
2025-11-18 15:45:01 +01:00
tests Implement a test for --clear 2025-11-18 15:45:01 +01:00
.gitignore Initial commit 2017-08-11 19:53:34 +02:00
.woodpecker.yml Add a when: to the woodpecker config. 2025-10-28 23:23:53 +01:00
pomerge.py Implement a test for --clear 2025-11-18 15:45:01 +01:00
pyproject.toml Implement first test. 2025-11-18 15:39:15 +01:00
README.rst Implement --clear 2025-11-18 15:28:00 +01:00

pomerge

image

Script to merge translations from a set of po files to other set of po files.

pomerge does not care about .po file names, a translation from one file can land in another as long as their msgid are identical.

Pomerge is part of poutils!

Poutils (.po utils) is a metapackage to easily install useful Python tools to use with po files and pomerge is a part of it! Go check out Poutils to discover the other tools!

Usage

Basic usage is pomerge --from source.po --to dest.po, see pomerge --help for more.

--from and --to are optional, when not given, pomerge will use a temporary file. So:

pomerge --from a/**/*.po --to b/**/*.po

is strictly equivalent to:

pomerge --from a/**/*.po
pomerge --to b/**/*.po

One more option is --clear that make pomerge forgot what it learned, this can be useful to avoid mixing languages:

pomerge --from a/**/*.po --to b/**/*.po --clear

is equivalent to:

pomerge --from a/**/*.po
pomerge --to b/**/*.po
pomerge --clear

The wrapping of your .po files is not kept by pomerge, completely destroying the readability of git diffs, to fix this I use powrap.

Recipes

Propagating translations from a directory to another

When you're having two directories with .po files and want to copy translations (msgstr) from one to another, even if the hierarchy is not the same, run:

pomerge --from ../contributors/**/*.po --to **/*.po

In this case, two options can be useful:

  • --no-overwrite: Avoid touching already translated strings.
  • --mark-as-fuzzy: Mark all new translations as fuzzy, useful when you know you'll have to proofread the translations.

Propagating known translations

In big projects, there may be multiple occurrences of the same string in different .po files, to automatically fill blanks with already translated ones, use:

pomerge --no-overwrite --from **/*.po --to **/*.po

The --no-overwrite is useful if the same msgstr has already been translated twice, but differently (depending on the context maybe), the --no-overwrite will prevent one to be overwritten by the other.

Synchronizing translation between git branches

If you're having multiple branches of your documentation to track multiple branches of your project, you may want to synchronize known translations between branches, you can do it like this:

git checkout master       # The place where your contributors work
pomerge --from **/*.po    # Make pomerge "learn" this set of translations
git checkout old_version  # The translation for an old branch
pomerge --to **/*.po

This way you can still make old translation progress a bit while focusing only on the current master.