Get translation of a component at runtime

All announcements, questions and issues related to the TsiLang Components Suite.
Post Reply
JavierOrellana
Posts: 8
Joined: Mon Sep 04, 2006 9:56 am

Get translation of a component at runtime

Post 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
isiticov
Site Admin
Posts: 2385
Joined: Thu Nov 21, 2002 3:17 pm

Post 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.
Best regards,
Igor Siticov.
JavierOrellana
Posts: 8
Joined: Mon Sep 04, 2006 9:56 am

Post by JavierOrellana »

thnks

works perfectly :D
Post Reply