Translating a form without tsilang component

All announcements, questions and issues related to the TsiLang Components Suite.
Post Reply
ivanov v k
Posts: 2
Joined: Sun Nov 30, 2003 12:19 am

Translating a form without tsilang component

Post by ivanov v k »

I wonder if it's possible to translate a form which has no tsiLang component on it. In my package I have to translate a dialog which is called from another package, so i cant just put a component on it (this package must be free of tsilang). But i can access the dialog form. So right now i'm using this:
With TFrmFindDlg(Form) Do
Begin
Caption := siLang.GetText('IDS_F_0');
btCancel.Caption := siLang.GetText('IDS_F_1');
...
What i am looking for is a way to load into tsilang component names and values, for example, for captions. Then, at runtime i would assign, let's say, _form_ property of tsilang, tsilang would scan the form for components with specified names and translate their captions. Is this somehow possible?
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

No, this is not possible to automatically translate form wihout TsiLang component on it. The only way to fo this is the way you've used, using GetText() or GetTextOrDefault() methods to retrieve strings and assign them to UI elements of such form.
ivanov v k
Posts: 2
Joined: Sun Nov 30, 2003 12:19 am

Post by ivanov v k »

OK, thank you anyway :) Maybe you will consider creating such a component...
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Btw, I cas suggest you to use the following and you will be able to achieve what is needed (I hope):
1. Create TsiLang manually on the form which needs to be translated:

Code: Select all

var
    SiLangForFindFrm: TsiLang;
-------

Code: Select all

  SiLangForFindFrm := TsiLang.Create(Form); // here Form is your external form component
  SiLangForFindFrm.LangDispatcher := siLangDispatcher1; // here siLangDispatcher1 is some global dispatcher which is used in your project. This could be skipped if no dispatcher is used to switch languages.
  SiLangForFindFrm.BuildList;
2. Save to SIL/SIB file the translations content for your FrmFindDlg form only once at run-time:

Code: Select all

  SiLangForFindFrm.SaveAllToFile('somesilfile.sil', '!@#$%');
And after saving you may comment the line above in order to do not save this info any more since file is created already.

3. Translate created SIL file.

4. Insert code for loading the contant of this SIL file into TsiLang component:

Code: Select all

  SiLangForFindFrm.LoadAllFromFile('somesilfile.sil', True);
5. After that I suppose when switching languages in dispatcher component your external form will be translated as well.

Hope this helps.
Post Reply