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.
Release files for pomerge 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pomerge-0.2.1.tar.gz | 6.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pomerge-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.9 kB
Release files / pomerge-0.2.1.tar.gz
| Download URL | pomerge-0.2.1.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e78c6e55a9643f5b0ab105c952550c4783314de245b57ad428765515647322ee
|
|
BLAKE2b-256 checksum How to use checksums |
a0ab1b1c80a42ca8a8411e1eff41cb68cf56d701f2eb984c208791fbf8ac8629
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / pomerge-0.2.1-py3-none-any.whl
| Download URL | pomerge-0.2.1-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f14f093ea7cdf5dbb9d8da8ed789e48b47f7f4073effd0820cb605013f46d692
|
|
BLAKE2b-256 checksum How to use checksums |
ec429403831307611e399fd0fb3f858088aca3905e970dfe9ca0e5aad7cf4806
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|