A special kind of constant declaration block is the Resourcestring block. Resourcestring declarations are much like constant string declarations: resource strings act as constant strings, but they can be localized by means of a set of special routines in the objpas unit. A resource string declaration block is only allowed in the Delphi or Objfpc modes.
The following is an example of a resourcestring definition:
All string constants defined in the resourcestring section are stored in special tables. The strings in these tables can be manipulated at runtime with some special mechanisms in the objpas unit.
Semantically, the strings act like ordinary constants; It is not allowed to assign values to them (except through the special mechanisms in the objpas unit). However, they can be used in assignments or expressions as ordinary string constants. The main use of the resourcestring section is to provide an easy means of internationalization.
More on the subject of resourcestrings can be found in the Programmer’s Guide, and in the objpas unit reference.
Remark Note that a resource string which is given as an expression will not change if the parts of the expression are changed:
If the localization routines translate Part1 and Part2, the Sentence constant will not be translated automatically: it has a separate entry in the resource string tables, and must therefore be translated separately. The above construct simply says that the initial value of Sentence equals Part1+’ ’+Part2.
Remark Likewise, when using resource strings in a constant array, only the initial values of the resource strings will be used in the array: when the individual constants are translated, the elements in the array will retain their original value.
This will print “Yes.” or “No.” depending on the value of B, even if the constants Yes and No have been localized by some localization mechanism.