[Lazarus] Resource string constants support in the Object Inspector

Marc Weustink marc.weustink at cuperus.nl
Mon Mar 17 11:30:54 CET 2008


Graeme Geldenhuys wrote:
> On 17/03/2008, ik <idokan at gmail.com> wrote:
>> I find it weird a bit, but I also see the power in it.
> 
> I think it will be very handy!  Currently you assign a hard-coded
> string like 'Hello' to a button's caption and then later in your code
> you need to write something like
> 
>    MyButton.Caption := rsHello;
> 
> just to replace what the Object Inspector did the first time round.
> This seems like a waist. Why couldn't the Object Inspector use the
> resource string in the first place.
> 
> One issue that might come up in Lazarus (not fpGUI) is a question of
> timing.  What if rsHello is assigned before correct localization was
> loaded.  fpGUI does localization handling in Application.Initialize

We have thought about this OI localization long ago. I'll try to recall 
what we have thought of.

Every localizable property will be declared as a TTranslateString (and 
not as String).
When such a property is written, the IDE also generates a constant for 
it. Then on loading, the lcl catches those properties and will replace 
them with the proper translation.
However, one problem we had (and there the idea stopped) is how to 
unique identify those constants in such way that it is clear on what 
instance the constant is used (so that you can translate them).

Marc




More information about the Lazarus mailing list