Page 1 of 1

Get translation of a component at runtime

Posted: Tue Sep 05, 2006 4:14 pm
by JavierOrellana
hello,

I want to get translation of a component at runtime (caption of a button for example) to assign it to a label.

How can i do it without duplicating translation on the label (because it is the same)?

I tested use: siLang.GetText('component.name') but did not work.

thnks & regards,

Javier Orellana
www.tmssoft.com

Posted: Wed Sep 06, 2006 3:56 am
by isiticov
Hello,

GetText() works for user defined strings only.
You can use GetStringValue() value method:

Code: Select all

    function GetStringValue(const AStrings: TStrings; AName: Tstring; ALang: Integer):
      Tstring;

AStrings- properties translations list, like Captions, Hints...
AName- string identifier, 'Label1' in your case
ALang- translation language index to extract.
Sample usage:

Code: Select all

Button1.Caption := siLang1.GetStringValue(siLang1.Captions, 'Label1', siLang1.ActiveLanguage);
But I think more useful in your case would be to assign both label and button caption in code and later use TsiLang Expert to scan your source and make replacement (translation) for this hardcoded string.

Posted: Wed Sep 06, 2006 10:48 am
by JavierOrellana
thnks

works perfectly :D