Having started off with an incomplete gettext .pot file, the resulting .po translations file now includes a large number of translation strings that were not originally in the .pot file.
How can I backwards generate a .pot file for other languages (strings with blank translation entries) from a translated .po file?
Thanks for your help.
To open PO and POT files, you can use any text editor that supports the format (such as Notepad, Sublime Text, or Notepad++), use specialized software (like Poedit), or Localazy - the online translation management system explicitly made for working with translation file formats.
A . PO file is a portable object file, which is text-based. These types of files are used in commonly in software development. The . PO file may be referenced by Java programs, GNU gettext, or other software programs as a properties file.
1.4 Files Conveying Translations po files means Portable Object, to distinguish it from . mo files, where MO stands for Machine Object. This paradigm, as well as the PO file format, is inspired by the NLS standard developed by Uniforum, and first implemented by Sun in their Solaris system.
I think that the cleanest approach would be to use the solution suggested by Peter Eisentraut:
msgfilter -i xx.po -o new.pot true
You can also keep the gettext header by adding the --keep-header
before the final true
argument. In this case you need to check the resulting header because it may contain language-specific instructions (like the number of plural rules).
For Windows users: in order to use this approach, you need a program that acts like true
(that is, it does nothing except running succesflully), like the true
for Windows I wrote for exactly this reason.
You can use something like this:
msgfilter -i xx.po -o new.pot true
msgfilter
applies a program to all translations in a file, and true
is just some program that doesn't output anything for any input.
You will probably need to massage the header comment a bit after this to make it really look like a fresh POT file.
This took ages to figure out a way of doing it, but in the end I found a solution using Notepad++. From the Search|Replace... menu I was able to Replace All with a regular expression.
Find: msgstr ".*"
Replace with: msgstr ""
You don't. You generate the .pot file from the source code. msgmerge
then takes the new .pot file and the existing .po file, and merges old entries into the new file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With