Proper way to create / manage gettext (.po, .pot) files?

So I’m trying to figure out how .po and .pot files work, seeing as this is what WordPress seems to use. But I can’t wrap my head around it.

I get that a .pot file is a template file that indicates what .po files need to have translations for. What I don’t get it how you’re supposed to add entries to these files?

Read More

I can find references on how to do it through the CLI but none of the GUI apps I’ve tried seem to support this. Is it common for the developer to just use the CLI to create these .pot files and then translators just provide the .po files?

Am I missing something? Are there no tools used that take care of the whole process?

It all looks good in theory but atm the whole process of managing translations just seems ridiculous, I’d expect an industry standard these days to be a bit more polished and user friendly.

I should note, I don’t have any problem understanding how to work it myself.. I’m just trying to figure out how everyone does this with non-programmers in their team. I can’t possibly ask them to open up their terminal and execute a bash command.

Related posts

Leave a Reply

5 comments

  1. I can find references on how to do it through the CLI but none of the GUI apps I’ve tried seem to support this.

    Did you see Poedit? Cross-platform GUI for preparing and producing gettext-translations (with some limitation compared to fresh CLI-tools)

    Is it common for the developer to just use the CLI to create these .pot files and then translators just provide the .po files?

    Yes, CLI have more flexibility in some areas and isn’t too hard to use (after learning curve)

    Am I missing something? Are there no tools used that take care of the whole process?

    Just learn Poedit (while xgettext&Co is still better)

    I’m just trying to figure out how everyone does this with non-programmers in their team

    Translators have Poedit (which they know how to use) and get updated pots, return changed po back

  2. Editing .po files is easier than you can imagine. You can open a .po file by any text editor such as gedit on Linux or Notepad on Windows. After the header, you will see the following:

    msgid "Something"
    msgstr "Translation of Something"
    

    and the file goes on and on.
    If you want to change couple of translations, then , use gedit on Linux or notepad on windows, open the file, and just change the text in quotes after msgstr. Then save the file.

    The .po file then has to be changed to binary format (mo) so that the server can understand it. This is done using one simple command

    msgfmt source.po -o destination.mo
    

    For this command to run successfully on Ubuntu, you have to have gettext installed by doing

    sudo apt-get install gettext
    

    After generating the destination.mo file, you can just copy it to your server with the same name as the old .mo file (replacing it) and you are ready to go

    I am using Gtranslator on Ubuntu. It seems to be much easier and better than POedit. to install on Ubuntu:

    sudo apt-get install gtranslator