9.4 GNU gettext

The unit gettext provides a way to internationalize an application with the GNU gettext utilities. This unit is supplied with the Free Component Library (FCL). it can be used as follows:

for a given application, the following steps must be followed:

  1. Collect all resource string files and concatenate them together.
  2. Invoke the rstconv program with the file resulting out of step 1, resulting in a single .po file containing all resource strings of the program.
  3. Translate the .po file of step 2 in all required languages.
  4. Run the msgfmt formatting program on all the .po files, resulting in a set of .mo files, which can be distributed with your application.
  5. Call the gettext unit’s TranslateResourceStrings method, giving it a template for the location of the .mo files, e.g. as in
    TranslateResourcestrings('intl/restest.%s.mo');

    the %s specifier will be replaced by the contents of the LANG environment variable. This call should happen at program startup.

An example program exists in the FCL-base sources, in the fcl-base/tests directory.