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.