Is it possible to combine two .po translation files together?

We have two .po files, each from different branches of a piece of software.

We need to combine these into a single .po file.

There are duplicates between the two files, and the ideal handling would be for one file's strings to be favoured (consistently).

We have a SUSE system so the --output-file doesn't seem to have the behaviour of ignoring/merging duplicates which the Sun version has according to a man page I found from a web search. (We do not have a Sun machine handy!)

13.10.2009 17:56:28
Possible duplicate of Merge 2 GetText files
DanMan 8.10.2015 13:06:02

What you are looking for is the msgcat util, it concatenates and merges the specified PO dictionaries.

This is part of gettext utils, for more information please consult gettext manual page on msgcat.

10.12.2019 13:39:32
Usage as simple as regular cat, but check all output for "fuzzy" (you need to pick one version there).
Ctrl-C 30.08.2013 13:09:34
NOTE: Inserted the HTML link into the answer, so @rve's comment doesn't make sense anymore. ;)
lxg 6.11.2014 10:40:57
As a side-note, while msgcat handles collisions when the same string appears in several po files, the --use-first options allows to favor the translation of one of the files over the others.
liberforce 5.06.2015 09:20:01

I use msgmerge:

msgmerge [old_file.po] [new_file.po] > output.po

It works for me, but be aware that it does a silly merge, it is, it discards the entries in the old_file (new file overwrites old one).

12.06.2014 13:16:02
The msgmerge file is meant for applying new template to existing translation. It will discard any localizations in the second file by design! Use msgcat for merging localization data. Sadly, it only does stupid catenation instead of real 3-way merge you would want to have with version control.
Mikko Rantalainen 25.04.2013 10:09:07
This is also bad if you have some of the messages in both files. Then you will get "some.po:16008: ...this is the location of the first definition" style messages and it won't concatenate the files. How can I use the first available translation from ANY file?
nagylzs 3.11.2015 06:41:18

you can use poedit. To merge your current po-file, you must to open it and click:

  • Catalog > Update from POT-file.
  • Set the filter to all files and select your second.po file

Poedit will show you new & obsolete strings

22.04.2013 10:15:45
If you want GUI, I'd suggest using virtaal if that's available for your operating system.
Mikko Rantalainen 25.04.2013 10:10:17
I think poEdit works just fine for this kind of task! Thanks for the answer, it helped me!
markus 18.11.2013 19:56:39
Poedit doesn't transfer the actual translations that way though, just the msgids.
DanMan 5.02.2015 11:37:44
What do you mean @DanMan? I needed to update the catalog as the source included "notes for translators" and it also kept the actual translations by updating the catalog that way. The msgstr are there along with the (new) #. notes.
Firsh - 18.12.2019 20:53:06