Next: , Previous: , Up: The language   [Contents][Index]

5.39 Internationalisation

Librep has support for internationalisation (or i18n) of text messages, using the GNU gettext implementation (see Overview in The GNU gettext Manual), a run-time library managing the mapping between text strings in the programmer’s native language and in the language of the end user.

Three functions are provided to access the message catalogues maintained by GNU gettext. Import the rep.i18n.gettext module to load them.

Function: _ string

Attempt to find a native language equivalent of string. If no equivalent is found the original string is returned.

Note that this function is always defined, even if the gettext module hasn’t been required. In this case it always returns the original string.

Function: bindtextdomain domain directory

Tell gettext that message catalogues for message domain domain (a string) can be found under the directory called directory.

Function: textdomain domain

Note that any strings that are to be translated in the future (until the next call to textdomain) are in the domain called domain (a string).

The usual method of constructing message catalogue templates (.pot files) is to run xgettext on the C source files of the program (that have been annotated for i18n). librep provides the rep-xgettext program to perform the same task for files of Lisp code.