Gettext is an internationalization and localization (i18n) library which is commonly used for writing multilingual programs. Its most popular implementation is that of the GNU project.
Gettext is an internationalization and localization (i18n) library which is commonly used for writing multilingual programs. Its most popular implementation is that of the GNU project.
I18n with gettext works by marking up translatable strings in the source code, usually by wrapping them with a function call. The xgettext
tool extracts these strings and creates a text file listing them. This file is called the template and its name usually ends in ".pot".
The msginit
tool creates a new text file mapping the extracted strings to their translation in a given locale, having the ".po" extension. Finally the msgfmt
tool creates an optimized representation of the translation mappings that is then used at runtime. For most programs this is a binary file ending in ".mo", but it is also possible to create other formats, for example a java ResourceBundle.
There are specialized editors for editing the ".mo" files, which can remember already translated strings and contain databases of repeatedly used words.