How can I merge 2 .POT files (translation files)
Asked Answered
J

4

19

I have the following situation:

One product which I want to translate, that has two separate websites, one for admins, one for customers.
The codebase is CakePHP.
Both sites are completely separate from each other, they are complete CakePHP sites.
And they both have A LOT of strings in common.

So, with CakePHP I generate the .pot files for each site, but I'd love to give translators ONE file, with the unique strings in both .pot files.

They'd give me back one .po file with the strings for both sites, and I'll just copy the same file to both sites, so I'll have .po files with extra strings that the code will not use, but that shouldn't be a problem.

So the question essentially is... How can I merge two .pot files?

  • I need to get a new file that has no duplicate strings.
  • Ideally, it'll keep (and for duplicate strings, append) the comments before each string that CakePHP adds, specifying where the string was found, but if this is not done, that's fine, I can live without it. (see below for an excerpt of the .pot file for a clarification on this)

Do you know of any tools that'd let me do this? I'd really like to avoid having to write my own.


These are the comments I'm talking about above:

#: \controllers\accounts_controller.php:118
#: \controllers\customer_documents_controller.php:75
msgid "Parent Customer not specified"
msgstr ""
Jelene answered 29/10, 2010 at 14:24 Comment(0)
N
33

Ok, so the tool to do this is msgcat

msgcat *.pot > all.pot

If you're on Windows, install cygwin, and make sure you have the gettext-devel package, because msgcat is not in the regular gettext package.

Node answered 29/10, 2010 at 14:56 Comment(3)
@J.Pablo Fernández: can you plese post the command for merging.Maplemaples
In the case of POT files (as opposed to PO files) I suggest using “--use-first” as well, not to end up with unnecessarily-duplicated stuff.Rexer
Maybe msguniq is suitable to post-process the msgcat output to avoid duplication, @Gallaecio?Eleanoreleanora
C
4

msgcat should not be the right answer, msgcat is good for .po file but it won't work well on .pot file due to document that:

To concatenate POT files, better use xgettext, not msgcat, because msgcat would choke on the undefined charsets in the specified POT files.

The right one is:

xgettext input/*.pot -o out.pot

Cyan answered 20/6, 2021 at 12:24 Comment(0)
D
0

Merge two .pot files into one:

msgcat --use-first -o Messages.pot csMessages.pot XamlMessages.pot

--use-first - use first available translation for each message, don't merge several translations

-o - write output to specified file

Devitalize answered 9/11, 2022 at 11:24 Comment(0)
B
-1

the command is:

msgcat inputfile1 inputfile2 ... > outpo
Blaspheme answered 27/7, 2012 at 5:45 Comment(2)
Why the downvote? J. Pablo's answer is better, but this is not technically wrong or misleadingLaplante
I'd guess the downvoting is done because this answer contains nothing in addition to existing answer and this one was added nearly two years after the better answer.Bowel

© 2022 - 2024 — McMap. All rights reserved.