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:
- Compiler creates .rst file.
- rstconv tool converts to .po (input for gettext) This file can be translated to many languages. All standard gettext tools can be used.
- Gettext creates .mo files.
- .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. In fact, output to .rc files, i.e. source texts for resource compiler, is already available in rstconv - however, portable functions for loading the texts from such DLLs are missing (see point 3 below). The same applies to the third output format supported by rstconv at the moment, IBM OS/2 MSG files.
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:
- Update rstconv so it can output another format.
- Tools to manipulate the other format.
- 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.
[sysutils] SErrInvalidDateTime="%S" is not a valid date/time indication.
[sysutils] SErrInvalidDateTime="%S" is geen geldige datum/tijd aanduiding.
This would allow reuse of various files.