[fpc-devel] the new resourcestring in const translation

Anton Kavalenka anton.kavalenka at gmail.com
Fri Sep 9 18:51:50 CEST 2011


On 09.09.2011 18:27, Sergei Gorelkin wrote:
> 09.09.2011 18:36, Martin пишет:
>> fpc recently added the ability to translate
>> const Foo: String = resourcestring;
>>
>> if resourcestring changes so does Foo
>> Any way to work around this?
>>
> Probably only by duplicating the literal value which is used to 
> initialize.
>
>> because in C:\lazarus_latest\components\synedit\syneditstrconst.pp
>> there are a lot of strings initialized that way with the intend of 
>> the old behaviour => keep an
>> untranslated copy.
>>
>> Also: Is that intended for typed const?
>> Foo in above could have been changed by user in the meantime.
>
> Yes, trying to be Delphi-compatible. In Delphi, such consts are 
> translated. Delphi translates them once during initialization, but in 
> FPC this is impossible to do because translation typically happens 
> later, so the only way is to hook into SetResourceStrings.
>
> Personally I don't think this is a valuable feature, but the matter of 
> fact is all Delphi features are implemented in FPC sooner or later - 
> so why not to do it sooner...
>
> Regards,
> Sergei
>
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel

This being translated always and is Delphi compatible

resourcestring
   sString1='Some localizable constant'
   sString2='Another localizable constant'

const
   sStrings:array[0..1] of PResStringRec=(@sString1, at sString2);

Regards,
Anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20110909/8a487b01/attachment.html>


More information about the fpc-devel mailing list