In a world as globalized as the one we live in, the development of any application must involve translation into as many languages ​​as possible. To do this, we are provided with various tools and standardized formats that simplify the task of working with these languages.

.PO files (Portable Object)

It is the original file of the translation, of which there is one for each language, it has a specific template format, divided into two parts:

- Message identifier - Translation

In the .po files, this second part is filled in for each language. Therefore, for each project (or part of the project) that we want to translate, we will always have a .POT file and as many .PO files as the languages ​​into which we translate the software.

For example:

#: path_del_fichero:numero_de_linea
msgid "Move To"
msgstr "Mover A"

 

.MO files (Machine Object, machine objects) Although with the .PO file, the functionality could be provided correctly, since it is plain text, access to it is slower than in binary, therefore it is recommended to compile it, and thus speed up the speed and loading time. A .MO file, the compilation of a .PO file so that gettext takes less time to find the translated messages.   Compilation   To generate a mo file from the original we will use the msgfmt command (compiles a catalog of messages to binary format)

# msgfmt ficheroOrigen_es.po -o LC_MESSAGES/ficheroDestino.mo

If, on the other hand, what we want is to decompile it, to obtain the original we will do it with the msgunfmt command (decompiles a catalog of messages to binary format)

# msgunfmt ficheroOrigen.mo > ficheroDestino_es.po

Also for Windows platforms we can use PoEdit.