Page 1 of 1

User may create forms at runtime

Posted: Wed Aug 10, 2005 7:48 am
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

Posted: Wed Aug 10, 2005 11:49 am
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.

Posted: Wed Aug 10, 2005 9:00 pm
by Eric ten Westenend
Thanks, will try it directly.

Posted: Thu Aug 11, 2005 7:20 am
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

Posted: Thu Aug 11, 2005 8:23 am
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.

Posted: Thu Aug 11, 2005 10:24 am
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

Posted: Thu Aug 11, 2005 12:00 pm
by isiticov
Just assign for each created component the Name property. TsiLang skips all components that have no Name property defined.

Posted: Thu Aug 11, 2005 4:52 pm
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

Posted: Thu Aug 11, 2005 6:15 pm
by isiticov
:) Only using TsiLangRT. Or as I said earlier using SIL Editor OLE server.