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?
Translating a form without tsilang component
-
- Posts: 2
- Joined: Sun Nov 30, 2003 12:19 am
-
- Posts: 2
- Joined: Sun Nov 30, 2003 12:19 am
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:
-------
2. Save to SIL/SIB file the translations content for your FrmFindDlg form only once at run-time:
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:
5. After that I suppose when switching languages in dispatcher component your external form will be translated as well.
Hope this helps.
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;
Code: Select all
SiLangForFindFrm.SaveAllToFile('somesilfile.sil', '!@#$%');
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);
Hope this helps.