Page 1 of 1

How to translate 3rd party dialogs?

Posted: Thu Jan 19, 2006 3:16 pm
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.

Posted: Thu Jan 19, 2006 3:21 pm
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.

Posted: Thu Jan 19, 2006 3:24 pm
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.

Posted: Thu Jan 19, 2006 4:02 pm
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.

Posted: Thu Jan 19, 2006 4:47 pm
by moelski
Hi!

Can I try this solution with the demoversion of TsiLang?

Posted: Thu Jan 19, 2006 4:57 pm
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.

Posted: Thu Jan 19, 2006 5:03 pm
by moelski
Ok, I´ll give it a try tomorrow and post my results here.

Greetz

Posted: Fri Jan 20, 2006 12:46 pm
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 ...

Posted: Fri Jan 20, 2006 2:26 pm
by isiticov
Glad to see this.

Posted: Tue Jul 18, 2006 9:47 am
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;

Posted: Tue Jul 18, 2006 10:01 am
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.

Posted: Tue Jul 18, 2006 10:12 am
by moelski
Hi !

What should I say.
Perfect support 8) !