MO files (de.gmo) mean Machine Object. MO files are meant to be read by programs, and are binary in nature. A few systems already offer tools for creating and handling MO files as part of the Native Language Support coming with the system, but the format of these MO files is often different from system to system, and non-portable. They do not necessary use `.mo' for file extensions, but since system libraries are also used for accessing these files, it works as long as the system is self-consistent about it. If GNU gettext is able to interface with the tools already provided with systems, it will consequently let these provided tools take care of generating the MO files. Or else, if such tools are not found or do not seem usable, GNU gettext will use its own ways and its own format for MO files. Files ending with `.gmo' are really MO files, when it is known that these files use the GNU format.
These PO files are best created by the xgettext program, and later updated or refreshed through the msgmerge program. The program xgettext extracts all marked messages from a set of C files and initializes a PO file with empty translations. Program msgmerge takes care of adjusting PO files between releases of the corresponding sources, commenting obsolete entries, initializing new ones, and updating all source line references. Files ending with `.pot' are kind of base translation files found in distributions, in PO file format, and `.pox' files are often temporary PO files.
This picture is drawn by Ulrich Drepper:
Original C Sources ---> PO mode ---> Marked C Sources ---.| .---------<--- GNU gettext Library | .--- make <---+ | | `---------<--------------------+-----------' | | | .-----<--- PACKAGE.pot <--- xgettext <---'.---<--- PO Compendium | | | ^ | | `---. | | `---. +---> PO mode ---. | +----> msgmerge ------> LANG.pox --->--------' | | .---' | | | | | `-------------<---------------. | | +--- LANG.po <--- New LANG.pox <----' | .--- LANG.gmo <--- msgfmt <---' | | | `---> install ---> /.../LANG/PACKAGE.mo ---. | +---> "Hello world!" `--------> install ---> /.../bin/PROGRAM -------'Many packages use `_' (a simple underline) as a keyword, and write `_("Translatable string")' instead of `gettext ("Translatable string")'. Further, the coding rule, from GNU standards, wanting that there is a space between the keyword and the opening parenthesis is relaxed, in practice, for this particular usage. So, the textual overhead per translatable string is reduced to only three characters: the underline and the two parentheses. However, even if GNU `gettext' uses this convention internally, it does not offer it officially. The real, genuine keyword is truly `gettext' indeed. It is fairly easy for those wanting to use `_' instead of `gettext' to declare:
#include <libintl.h> #define _(String) gettext (String)
xgettext -i --keyword=_ -o foo.pot *.cReads all given source files and extracts all to be translated strings into the specified output file (foo.pot). `-i' will indent multi-line strings nicely. Be warned, this will split lines and make them look ugly.
msgmerge -i -o lang.pox lang.po foo.potMerges already translated strings from the lang.po file with the new foo.pot file which contains all translatable strings. Obsolete translations are commented out and all source references are updated. `-i' will indent multi-line strings nicely.