Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-09

the new resourcestring in const translation

6 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin
fpc recently added the ability to translate
     const Foo: String = resourcestring;

if resourcestring changes so does Foo
Any way to work around this?

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.

Reply by email

Sergei Gorelkin
to Martin

09.09.2011 18:36, Martin пишет:

Show quoted text 6 lines
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.

Show quoted text 6 lines
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

Reply by email

Anton Kavalenka
to Sergei Gorelkin
Sergei Gorelkin wrote 33 lines
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 - 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,@sString2);

Regards,
Anton

Reply by email

cobines
to Sergei Gorelkin: 09.09.2011 18:36, Martin пишет: Probably only by duplicating the literal value which…

2011/9/9 Sergei Gorelkin :

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...

There was recently a fix to Lazarus where some buttons captions were stored as constants strings and were not able to be translated. Workaround was to create a function which returns a (then translated) resource also use such method in my application
and dislike the fact that I have to use additional code for it, so I actually find this feature useful.

cobines

Reply by email

Anton Kavalenka
to Marco van de Voort
Marco van de Voort wrote 7 lines
In our previous episode, Anton Kavalenka said: > This being translated always and is Delphi compatible It is if you use Delphi based resources for translating. It is not if you use thirdparty translation packages udner Delphi like e.g. dxgettext _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Lazarus default translator would work with this as well.

string is TResStringRec structure
I keep the pointer of the structure but not of the string data content (which is structure member) -
so translating content won't affect the structure pointer.

regards,
Anton

Reply by email