[fpc-devel] resourcestrings file

Michael.VanCanneyt at Wisa.be Michael.VanCanneyt at Wisa.be
Wed Dec 29 18:12:52 CET 2004



On Wed, 29 Dec 2004, Rimgaudas Laucius wrote:

> Hello,
> 
> i am intresting for what purpose resourcestring file is created when
> compiling program. Can it be translated and later compiled into executable?
> How this can be done?

The .rst file is created to provide a mechanism to localize your application.
Currently, only one localization mechanism is provided: gettext.

The steps are as follows:

1. Compiler creates .rst file.
2. rstconv tool converts to .po (input for gettext) 
   This file can be translated to many languages. All standard gettext tools can be used.
3. Gettext creates .mo files.
4. .mo files are read by gettext unit and all resourcestrings are translated.

The calls needed to translate all resourcestrings are in the objpas unit.
They are documented.

Nothing stops people from creating a mechanism that does not depend on gettext.
One could implement a mechanism to create resource DLL's (as delphi does) which 
contain the translated texts.

The reason gettext was chosen is that it's more or less standard on Unix.
But Gettext is horribly inefficient, so if someone has a better idea, please do.
Plus, GetText is context insensitive (it operates on the string itself), 
which is a drawback: sometimes the same word/sentence must be translated 
differently according to the context, and this is not possible.

To implement another mechanism, 3 things are needed:
1. Update rstconv so it can output another format.
2. Tools to manipulate the other format. 
3. Implement a unit that loads the other format at runtime.

this is also the reason we create an intermediate file format: this was the compiler
needs no knowledge of the translation tool. It just needs to create the .rst file.

An alternate way of doing it would e.g. be create a ini file per language, with a 
section for each unit used, and a key for each string.

-------english.ini-------------------
[sysutils]
SErrInvalidDateTime="%S" is not a valid date/time indication.
-------dutch.ini-------------------
[sysutils]
SErrInvalidDateTime="%S" is geen geldige datum/tijd aanduiding.
----------------------------------------

This would allow reuse of various files.

Michael.




More information about the fpc-devel mailing list