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 les and concatenate them together.
  2. Invoke the rstconv program with the le resulting out of step 1, resulting in a single .po le containing all resource strings of the program.
  3. Translate the .po le of step 2 in all required languages.
  4. Run the msgfmt formatting program on all the .po les, resulting in a set of .mo les, which can be distributed with your application.
  5. Call the gettext unit's TranslateReosurceStrings method, giving it a template for the location of the .mo les, e.g. as in
    TranslateResourcestrings('intl/restest.%s.mo');

    the %s specier 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 sources, in the fcl/tests directory.