How to generate a new .pot template from a translated .po file

When launched with an incomplete gettext .pot file, the resulting .po file now includes a large number of translation lines that were not originally in .pot .

How can I create a .pot file for other languages ​​(strings with empty translation) from a translated .po file?

Thanks for your help.

+6
source share
7 answers

It took a while to figure out a way to do this, but in the end I found a solution using Notepad ++. In the menu "Search | Replace ..." I managed to replace everything with a regular expression.

Find: msgstr ".*"

Replace with: msgstr ""

+1
source

You can use something like this:

 msgfilter -i xx.po -o new.pot true 

msgfilter applies the program to all translations in the file, and true is just a program that does not output anything for any input.

You will probably have to massage the header comment a bit afterwards to look like a new POT file.

+8
source

Not. You create a .pot file from source code. msgmerge then takes the new .pot file and the existing .po file and merges the old entries into a new file.

+1
source

I think the cleanest approach would be to use the solution suggested by Peter Eisentraut:

msgfilter -i xx.po -o new.pot true

You can also save the gettext header by adding --keep-header before the final argument true . In this case, you need to check the received header, because it may contain language-specific instructions (for example, the number of multiple rules).

For Windows users: to use this approach, you need a program that acts like true (that is, it does nothing but run succesflully), for example true for Windows. I wrote for this reason.

+1
source

So far, the command provided by @richhallstoke works with Linux and Mac

 msgfilter -i xx.po -o new.pot true 

On Windows, this does not work because we do not have the true command.

I just released an online tool that performs this operation (among other things): just drag and drop your .po file into the browser, click the "Tools" icon and click "Convert to .pot".

PS: this online tool is FOSS: its source code on GitHub .

+1
source

if you want to update translation strings, you do not need a .pot file. From poedit: directory, update from .pot file, then in the browser window change the .pot files only to "all files", select your .po file and process

0
source

For one thing, the question is about the vim substitution command to make a .pot file from a translation of a completed .po file.

:% s / msgid \ _. \ {- \} msgstr \ (\ ("." \ _. \) \) / msgid \ 1msgstr "" \ r /

0
source

Source: https://habr.com/ru/post/887632/


All Articles