## Localization

Redet is fully internationalized, meaning that the program is written in such a way that all messages and labels can be localized without modification to the program itself. The system used is the Tcl version of GNU gettext. In this system, each string is looked up in a message catalog, which pairs strings in the original language with their translations. If there is an entry for it, the translation is used in place of the original string. If not, the original string is used. This allows translations to be used while they are still incomplete.

The message catalog to use is determined by the current locale. A fully specified locale consists of a language, a region (usually a country), and an encoding. For example, the locale es_ES.UTF-8 is the locale for Spanish as used in Spain encoded in UTF-8 Unicode. es_ES is the locale for Spanish as used in Spain encoded in the ISO-8859-1 (Latin-1) encoding, since this is considered the default for Spanish. This could be made explicit by using the locale specification es_ES.ISO-8859-1.

In a Unix shell the locale is defined by the settings of a set of environment variables. These include LANGUAGE, LANG, and LC_ALL. (Similarly named environment variables control non-linguistic aspects of the locale. For instance, the variable LC_NUMERIC determines the way in which non-monetary numbers are formatted. You can set the locale to be used by Redet either by setting the appropriate environment variables before starting Redet or by selecting a new locale while Redet is running via the Configure menu.

Providing a translation for a particular language means providing a message catalog containing English strings paired with their translations in the appropriate format, giving this file an appropriate name, and installing it where Redet will find it. The file name should consist of the locale name with the suffix .msgs. The locale name may contain only the language code, the language code and the region code, or the language code, region code, and encoding. Thus, es, es_es, and es_es.UTF-8 are all valid locale names for Spanish. The encoding is not specified as part of the file name, so only es.msgs and es_es.msgs are valid names for Spanish message files.

Redet expects to find message catalogs in a subdirectory called msgs of the directory in which the program itself is located. For example, if Redet is installed in /usr/local/bin/, message catalogs should be in /usr/local/bin/msgs. However, if the DebugP flag is set (using the command line option -d), message catalogs will be sought in a subdirectory named msgs in the current directory. On a Unix system the Makefile supplied with Redet will install the message catalogs provided with Redet in the correct location.

A message catalog is actually a Tcl program consisting of calls to the function ::msgcat::mcset. The first argument to each call is the locale. The second and third arguments are the source string and the corresponding translation string. For example, the entry for the Quit label on the File menu in the Spanish message catalog is:

    ::msgcat::mcset es "Quit" "Salir"

All strings should be written in UTF-8 Unicode. (It may, of course, be more convenient to write the translations initially in another encoding and then translate it.) The file template.msgs provided with the distribution contains all of the necessary entries with the translations left blank. If you wish to add a localization for your own language, make a copy of the template and fill in the empty strings. For details see the documentation for the Tcl msgcat module.

Next
Back to Table of Contents