How to translate 3rd party dialogs?

All announcements, questions and issues related to the TsiLang Components Suite.
Post Reply
moelski
Posts: 21
Joined: Thu Jan 19, 2006 2:28 pm
Location: Germany
Contact:

How to translate 3rd party dialogs?

Post by moelski »

Hi @all!

Today I gibe TsiLang a try. I´m searching for a good solution to translate our application.

The most things work really fine with TsiLang. But we have special Dialogs from another component (wpTools). There are screen preview dialogs for example.
Is there a way to translate these dialogs with TsiLang, too?

The main problem is the following: I don´t want to change anything within the wpTools code / forms. This would result in frequently changes if there are updates from wpTools.

Hopefully you can help me.
Greetz Moelski
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Hi,

If these dialogs use resourcestrings to initialize the UI element then you can easily translate them using Resource Strings Wizard from TsiLang Expert menu Tools->Wizards. You will need just to open your project's EXE in Wizard and select strings related to these dialogs.
Please let me know if this helps. Otherwise there is another "hack" for such situation but I hope it won't be needed.
Best regards,
Igor Siticov.
moelski
Posts: 21
Joined: Thu Jan 19, 2006 2:28 pm
Location: Germany
Contact:

Post by moelski »

Hi isiticov!

No, there are no recourcestrings which I could use.

There is a form (the dialog) with a set of components on it. That´s it.
Greetz Moelski
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

In such case we will need to use some "hacking". The procedure is as the following:
1. Create SIL/SIB file for these dialogs.
2. Translate this file .
3. Load it at run-time.

To create such SIL/SIB file you can use the following:
1. Create procedure MyScreenActiveFormChange
2.Assign the code like this:

Code: Select all

// replace 3rdPartyFormClassName with the class name for the dialog form
if (Screen.ActiveForm <> nil) (and Screen.ActiveForm.ClassName = '3rdPartyFormClassName') then
begin
  with TsiLangLinked.Create(Screen.ActiveForm) do
  begin
    BuildList;
    SaveAllToBinaryFile(... insert here the name of your SIB file); 
    // in order to save into SIL file just use SaveAllToFile()
  end;
end;
3. Assign the procedure from 1. to Screen.OnActiveFormChange event in your code.
4. Run your application and display such dialog to execute the code above

To load and translate dialogs you will need the similar code. Something like the following:

Code: Select all

if (Screen.ActiveForm <> nil) (and Screen.ActiveForm.ClassName = '3rdPartyFormClassName') then
begin
  with TsiLangLinked.Create(Screen.ActiveForm) do
  begin
    LoadAllFromBinaryFile(... insert here the name of your SIB file);
    // for SIL file use LoadAllFromFile()
    LangDispatcher := your_dispatcher_used_in_project;
  end;
end;
To load SIL/SIB file above you will need either:
1. Disctribute it with your application. Fits the best if you use external translation storing for the application as well.
2. You can place it into application's resource and save it to disk from resource into temporary folder. Also you may use LoadAllFromStream() method of TsiLang to load the content directly from TResourceStream. But in this case your will need to use SIL files since Stream functions are SIL oriented.

Hope this helps.
Last edited by isiticov on Thu Aug 03, 2006 5:52 pm, edited 1 time in total.
Best regards,
Igor Siticov.
moelski
Posts: 21
Joined: Thu Jan 19, 2006 2:28 pm
Location: Germany
Contact:

Post by moelski »

Hi!

Can I try this solution with the demoversion of TsiLang?
Greetz Moelski
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Yes, of course. The demo version contains just one limitation: Delphi or C++Builder must be running when you execute applications translated with TsiLang.
After upgrating to registered version all your work will be re-used so you won't loose any translation after upgrating.
Best regards,
Igor Siticov.
moelski
Posts: 21
Joined: Thu Jan 19, 2006 2:28 pm
Location: Germany
Contact:

Post by moelski »

Ok, I´ll give it a try tomorrow and post my results here.

Greetz
Greetz Moelski
moelski
Posts: 21
Joined: Thu Jan 19, 2006 2:28 pm
Location: Germany
Contact:

Post by moelski »

Hi !

Thank´s many time for your help! That works really great!!!

Now I have to check where to get the money for your component. It´s not one of the cheapest ...
Greetz Moelski
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Glad to see this.
Best regards,
Igor Siticov.
moelski
Posts: 21
Joined: Thu Jan 19, 2006 2:28 pm
Location: Germany
Contact:

Post by moelski »

Hi isiticov!

I use the following code to add 3rd party dialogs to my SIB file ...

Code: Select all

procedure TForm1.ActiveFormChange(Sender: TObject);
begin
  //Memo2.Lines.Add(Screen.ActiveForm.ClassName);
  if (Screen.ActiveForm <> NIL) and
     ((Screen.ActiveForm.ClassName = 'TWPPageProp')  or
      (Screen.ActiveForm.ClassName = 'TWPPreviewForm') or
      (Screen.ActiveForm.ClassName = 'TWPTableDialog')
       ) then
  begin
    with TsiLangLinked.Create(Screen.ActiveForm) do
    begin
      BuildList;
      SaveAllToBinaryFile(siLang1.GetTextOrDefault('LangFile.sib');
    end;
  end;
end;
Works fine ... so far. In my SIB file I have three languages: German, English and French. But the Dialogs have not the default headline. My headlines are German, English and French for the translation of Forms. The dialogs have the headlines Language N1, ... N2, ... N3.

What should I do to get the normal headlines there.
Code like this don´t works ...

Code: Select all

procedure TForm1.ActiveFormChange(Sender: TObject);
begin
  //Memo2.Lines.Add(Screen.ActiveForm.ClassName);
  if (Screen.ActiveForm <> NIL) and
     ((Screen.ActiveForm.ClassName = 'TWPPageProp')  or
      (Screen.ActiveForm.ClassName = 'TWPPreviewForm') or
      (Screen.ActiveForm.ClassName = 'TWPTableDialog')
       ) then
  begin
    with TsiLangLinked.Create(Screen.ActiveForm) do
    begin
      NumOfLanguages := 3;
      LangNames.Add('Deutsch');
      LangNames.Add('Englisch');
      LangNames.Add('Französisch');
      BuildList;
      SaveAllToBinaryFile(siLang1.GetTextOrDefault('LangFile.sib');
    end;
  end;
end;
Greetz Moelski
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

If you use TsiLangDispatcher then you can just assign LandDispatcher property of run-time created TsiLang-s. Otherwise, to define language names you can use:

Code: Select all

NumOfLanguages := 3; 
      LangNames[0] := 'Deutsch'; 
      LangNames[1] := 'Englisch'; 
      LangNames[2] := 'Französisch'; 
Hope this helps.
Best regards,
Igor Siticov.
moelski
Posts: 21
Joined: Thu Jan 19, 2006 2:28 pm
Location: Germany
Contact:

Post by moelski »

Hi !

What should I say.
Perfect support 8) !
Greetz Moelski
Post Reply