User may create forms at runtime

All announcements, questions and issues related to the TsiLang Components Suite.
Post Reply
Eric ten Westenend
Posts: 10
Joined: Fri Aug 05, 2005 6:59 am

User may create forms at runtime

Post by Eric ten Westenend »

Hello,

I'm new to TsiLanguage and wonder if this is possible.
With our application it's possible the user create a new database table and designs a form around it. Its is possible to include the new string in the sil file at runtime and let the user translate them?

Eric
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

On creating some form at run-time you can also create a TsiLang component on it and assign its dispatcher property to one used in project. After that you can perform the following:
1. Call BuildList method. This will create translations lists in TsiLang.
2. Call SaveAllToFile (SaveAllToBinaryFile) to save lists to file
3. Call LoadAllFromFile (LoadAllFromBinaryFile) to load lists from file.

Hope this helps.
Best regards,
Igor Siticov.
Eric ten Westenend
Posts: 10
Joined: Fri Aug 05, 2005 6:59 am

Post by Eric ten Westenend »

Thanks, will try it directly.
Eric ten Westenend
Posts: 10
Joined: Fri Aug 05, 2005 6:59 am

Post by Eric ten Westenend »

Hello,

I tried this:

On a buttonclick i runtime create a form with a groupbox on it with the items 'One' , 'Two'.
I also create a TsiLangLinked component on the form and connect it using
the "CommonContainer" and "LangDispatcher" to the "TsiLangDispatcher" and "TsiLangRT" components on the main form.

Now i can call TsiLangLinked method "BuildList" and "SaveAllToFile" but how can i call the sil editor to only edit the list created by "BuildList"

Eric
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Eric ten Westenend wrote: Now i can call TsiLangLinked method "BuildList" and "SaveAllToFile" but how can i call the sil editor to only edit the list created by "BuildList"
Could you please describe what do you mean?
In case you need to edit created SIL file then just run SIL Editor with this SIL file in command line. Or you can import SIL Editor type library and use COM interface to manage it.
Best regards,
Igor Siticov.
Eric ten Westenend
Posts: 10
Joined: Fri Aug 05, 2005 6:59 am

Post by Eric ten Westenend »

The code:

procedure TForm1.Button1Click(Sender: TObject);
var
f : TForm;
gb : TRadioGroup;
b : TButton;
begin
//create the form
f := TForm.Create(self);
f.Caption := 'Test form';
f.Position := poScreenCenter;

// create a rodiogroup on the form
gb := TRadioGroup.Create(f);
gb.Parent := f;
gb.Top := 50;
gb.Left := 50;
gb.Items.Add('Een');
gb.Items.Add('Twee');
gb.Items.Add('Drie');

// create a TsiLangLinked on the form
siLangLinked1:= TsiLangLinked.Create(f);
siLangLinked1.CommonContainer := siLangRT1;
siLangLinked1.LangDispatcher := siLangDispatcher1;

// Create a button to do the translation
b := TButton.Create(f);
b.Caption := 'Translate';
b.OnClick := DoClick;
b.Parent := f;
b.Top := 175;
b.Left := 50;

f.ShowModal;

f.Free;
end;

procedure TForm1.DoClick(Sender: TObject);
begin
siLangLinked1.BuildList;
siLangLinked1.SaveAllToFile('C:\Test.sil','#');
end;

After this i can open "Test.sil" but the sil file only contaings the caption on the form. Not the button neither the radiogroup.

I could mail you the project if you want.

Eric
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Just assign for each created component the Name property. TsiLang skips all components that have no Name property defined.
Best regards,
Igor Siticov.
Eric ten Westenend
Posts: 10
Joined: Fri Aug 05, 2005 6:59 am

Post by Eric ten Westenend »

Great, thanks, that worked! Life can be that easy.

Now, when i rightclick the TsiLangLinked component in designtime i can call the editor. Can't find a method on this component to do the same at runtime.

Can this be done?

Eric
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

:) Only using TsiLangRT. Or as I said earlier using SIL Editor OLE server.
Best regards,
Igor Siticov.
Post Reply