Run Time Strings

All announcements, questions and issues related to the TsiLang Components Suite.
Post Reply
Kev
Posts: 24
Joined: Fri Apr 01, 2005 5:56 pm

Run Time Strings

Post by Kev »

I have a ClientDataset where the fields are defined at Runtime. So, siLang does not know what to translate until after the program is run. How would I make those translation assignments in code during runtime.

thanks,
Kev
isiticov
Site Admin
Posts: 2385
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

In your code you can use:

Code: Select all

Field1.DisplayLabel := 'Some Caption';
After that you can run TsiLang Expert menu File->Source->With Form
and you will get something like:

Code: Select all

Field1.DisplayLabel := siLang1.GetTextOrDefault('IDS_1' (* 'Some Caption' *));
Hope this helps.

P.S. Source code translation is detailed described in help file and User's Guide.
Best regards,
Igor Siticov.
Kev
Posts: 24
Joined: Fri Apr 01, 2005 5:56 pm

GetText

Post by Kev »

I tried this, but I get Garbage at runtime even though all looks ok in the Translation Editor. The Charset is set to Russian, and the font is set to Arial Unicode. Everything else on the form is ok.

I am using a TntDBGrid from TntWare.

// This is in an OnChangeLanguage Event Handler
MainForm->TntDBGrid5->Columns->Items[0]->Title->Caption =
MainForm->siLang1-> >GetTextOrDefault("IDS_64" /* "Jt." */ );



In the Translation editor it looks like this:
IDS_64 Jt. Труба

thanks
Kev
Posts: 24
Joined: Fri Apr 01, 2005 5:56 pm

More GetText

Post by Kev »

Using the Exampl in the help file, this works:
ShowMessage(siLang1.GetText("IDS_64"));

Also the inspector tips show correctly in the IDE. Label->Captions also show fine, but the DBGrid colum titles and Button->Captions do not. I have tried with standard as well as Tnt....

any ideas?

thanks,
Kev
isiticov
Site Admin
Posts: 2385
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

This is because of Ansi to Wide string conversion (in case of Tnt usage) or due to different default locale (since TButton and some others are just wrappers of native Windows controls). If you use Tnt.. then your will need the methods that return WideString. The next version (6.0.1) will have GetTextW() and GetTextOrDefaultW() methods that will return WideString as result and will help you.
Best regards,
Igor Siticov.
Kev
Posts: 24
Joined: Fri Apr 01, 2005 5:56 pm

GetText

Post by Kev »

Thanks for the quick response. So there is no way for me to make this work at this time? I tried casting to a WideString, but that doesn't seem to work either. This is really turning into a real pain!

But thanks for your help.

Kev
Kev
Posts: 24
Joined: Fri Apr 01, 2005 5:56 pm

GetText

Post by Kev »

OK, I just reverted back to a Standart DBGrid instead of TntDBGrid and things seem to be working.

Now onward to the next hurdles.... TCharts and QuickReports. Preliminary results look like I can make those work.

thanks,
Kev
Post Reply