SiComponents Home Page SiComponents Forums
Here you will be able to get help and share your experience
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to translate 3rd party dialogs?

 
Post new topic   Reply to topic    SiComponents Forums Forum Index -> TsiLang Components Suite
View previous topic :: View next topic  
Author Message
moelski



Joined: 19 Jan 2006
Posts: 21
Location: Germany

PostPosted: Thu Jan 19, 2006 3:16 pm    Post subject: How to translate 3rd party dialogs? Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2103

PostPosted: Thu Jan 19, 2006 3:21 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
moelski



Joined: 19 Jan 2006
Posts: 21
Location: Germany

PostPosted: Thu Jan 19, 2006 3:24 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2103

PostPosted: Thu Jan 19, 2006 4:02 pm    Post subject: Reply with quote

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:

// 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:
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
Back to top
View user's profile Send private message
moelski



Joined: 19 Jan 2006
Posts: 21
Location: Germany

PostPosted: Thu Jan 19, 2006 4:47 pm    Post subject: Reply with quote

Hi!

Can I try this solution with the demoversion of TsiLang?
Back to top
View user's profile Send private message Visit poster's website
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2103

PostPosted: Thu Jan 19, 2006 4:57 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
moelski



Joined: 19 Jan 2006
Posts: 21
Location: Germany

PostPosted: Thu Jan 19, 2006 5:03 pm    Post subject: Reply with quote

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

Greetz
Back to top
View user's profile Send private message Visit poster's website
moelski



Joined: 19 Jan 2006
Posts: 21
Location: Germany

PostPosted: Fri Jan 20, 2006 12:46 pm    Post subject: Reply with quote

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 ...
Back to top
View user's profile Send private message Visit poster's website
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2103

PostPosted: Fri Jan 20, 2006 2:26 pm    Post subject: Reply with quote

Glad to see this.
Back to top
View user's profile Send private message
moelski



Joined: 19 Jan 2006
Posts: 21
Location: Germany

PostPosted: Tue Jul 18, 2006 9:47 am    Post subject: Reply with quote

Hi isiticov!

I use the following code to add 3rd party dialogs to my SIB file ...
Code:
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:
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;
Back to top
View user's profile Send private message Visit poster's website
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2103

PostPosted: Tue Jul 18, 2006 10:01 am    Post subject: Reply with quote

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:
NumOfLanguages := 3;
      LangNames[0] := 'Deutsch';
      LangNames[1] := 'Englisch';
      LangNames[2] := 'Französisch';

Hope this helps.
Back to top
View user's profile Send private message
moelski



Joined: 19 Jan 2006
Posts: 21
Location: Germany

PostPosted: Tue Jul 18, 2006 10:12 am    Post subject: Reply with quote

Hi !

What should I say.
Perfect support Cool !
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    SiComponents Forums Forum Index -> TsiLang Components Suite All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by p h p B B  © 2001, 2005 p h p B B  Group