GNU gettext for Delphi, C++ Builder and Kylix 1.2 beta
<<< Previous | Introduction | Next >>>

# Resourcestrings

If you have tried the Integrated Translation Environment of Borland Delphi, you will know about the `resourcestring` keyword. It works like this:

    resourcestring
      msg='Hello, World';

    begin
      ShowMessage (msg);
    end.

Delphi automatically replaces the reference to msg with a call to the system function `LoadResString()`, which retrieves the string "Hello, World" from the resource part of the executable. The Delphi ITE achieves its translation mechanism by redirecting these fetches to other files.

By including gnugettext.pas in your project, these fetches are replaced with another function, which translates all the strings. The default is, that resourcestrings are translated using the default textdomain, i.e. default.mo. In case you want the system to search other mo files, if the translation isn't found in default.mo just make some calls to the `AddDomainForResourceString`. It is very common to have the Delphi runtime translation in a file named delphi.mo, and this line in the .dpr file to make sure that the Delphi runtime is translated:

    AddDomainForResourceString ('delphi');

Using `resourcestring` is not recommended, because Delphi only handles ansistring this way - not Unicode. But it works.

<<< Previous | Home | Next >>>
More gettext functions | Up | Forms