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

# procedure bindtextdomainToFile (Domain,Filename:string);

If you want to use `gettext()` as a string translation table that is independent of languages, you might want to bind a domain to a specific file on the harddisk. For instance, you might want to translate the ISO language codes to English language names. This could be done like this:

    function GetLanguageName (isocode:string):string;
    var
      EnglishLanguageName:string;
    begin
      bindtextdomainToFile ('isocodes','c:\isocodes.mo');
      EnglishLanguageName:=dgettext('isocodes',isocode);
      Result:=dgettext('languagenames',EnglishLanguageName);
    end;

There are many ways this can be used. For instance, the `msgshowheader` command line tool uses `bindtextdomainToFile()` to fetch the header from a specific file that is given as parameter. It is done something like this:

    bindtextdomainToFile ('parameterfile',paramstr(1));
    writeln (dgettext('parameterfile',''));

The translation of the empty string is always the header.

<<< Previous | Home | Next >>>
procedure bindtextdomain(Domain:string; Directory:string); | Up | procedure GetListOfLanguages (domain:string; list:TStrings);