Having compiled a program with resourcestrings is not enough to internationalize your program. At run-time, the program must initialize the string tables with the correct values for the language that the user selected. By default no such initialization is performed. All strings are initialized with their declared values.
The objpas unit provides the mechanism to correctly initialize the string tables. There is no need to include this unit in a uses clause, since it is automatically loaded when a program or unit is compiled in Delphi or objfpc mode. Since one of these mode is required to use resource strings, the unit is always loaded when needed anyway.
The resource strings are stored in tables, one per unit, and one for the program, if it contains a resourcestring section as well. Each resourcestring is stored with its name, hash value, default value, and the current value, all as AnsiStrings.
The objpas unit offers 2 methods to set the current value of the strings:
type TResourceIterator = Function (Name,Value : AnsiString; Hash : Longint; arg:pointer) : AnsiString; Procedure SetResourceStrings (SetFunction: TResourceIterator; arg: pointer); Procedure SetUnitResourceStrings (UnitName: string; SetFunction: TResourceIterator; arg: pointer);
Two other function exist, for convenience only:
Function Hash(S: AnsiString): longint; Procedure ResetResourceTables; Procedure FinalizeResourceTables;
Here is a short explanation of what each function does. A more detailed explanation of the functions can be found in the Reference Guide.