This approach has 2 advantages: rst of all, the value of the string is always present in the program. If the programmer doesn't care to translate the strings, the default values are always present in the binary. This also avoids having to provide a le containing the strings. Secondly, having all strings together in a compiler generated le ensures that all strings are together (you can have multiple resourcestring sections in 1 unit or program) and having this le in a xed format, allows the programmer to choose his way of internationalization.
For each unit that is compiled and that contains a resourcestring section, the compiler generates a le that has the name of the unit, and an extension .rst. The format of this le is as follows:
If the unit contains no resourcestring section, no le is generated.
For example, the following unit:
unit rsdemo;
{$mode delphi} {$H+} interface resourcestring First = 'First'; Second = 'A Second very long string that should cover more than 1 line'; implementation end. |
Will result in the following resource string le:
# hash value = 5048740 rsdemo.first='First' # hash value = 171989989 rsdemo.second='A Second very long string that should cover more than 1 li'+ 'ne' |
The hash value is calculated with the function Hash. It is present in the objpas unit. The value is the same value that the GNU gettext mechanism uses. It is in no way unique, and can only be used to speed up searches.
The rstconv utility that comes with the Free Pascal compiler allows to manipulate these resource string les. At the moment, it can only be used to make a .po