Question from New User

All announcements, questions and issues related to the TsiLang Components Suite.
Post Reply
mhtrozzo
Posts: 3
Joined: Tue Jul 13, 2004 12:45 am

Question from New User

Post by mhtrozzo »

Hi,

I've downloaded TsiLang for testing in order to internationalize a project on which I'm working. One thing that is appealing is that endusers can make translations themselves when needed rather than having to pay a translator to add a language that may only be used by a small number of people.

One important question I have that isn't clear to me..here's the scenario: I define a couple of languages that I'm already familiar with (English and German) in my project. Can an enduser define a new language (say, Spanish) even though it has not yet been defined at design time? Would this eventuality be anticipated in code or is there another way that it is done?

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

Post by isiticov »

Actually, in order to provide functionality to automatically add new language you will need to make some coding.
I would suggest you the following scenario:
1. You ship the SIL or SIB file among with your application and use loading translations at run-time.
2. In your code you add something like the following:

Code: Select all

procedure TForm1.LangMenuClick(Sender: TObject);
begin
  siLangDispatcher1.ActiveLanguage := TMenuItem(Sender).Tag;
end;

procedure TForm1.FormShow(Sender: TObject);
var
  MI: TMenuItem;
  I: Integer;
begin
  // this code shall be executed when dispatcher already loaded 
  // translations and amount of languages is defined
  for I := 1 to siLangDispatcher1.NumOfLanguages do
  begin
    MI := TMenuItem.Create(Self);
    MI.Caption := siLangDispatcher.Langnames[I - 1];
    MI.Tag := I;
    MI.OnClick := LangMenuClick;
    // LangaugeMenu is the menu item that holds languages
    LanguageMenu.Add(MI);
  end;
end;
3. You may also distribute the SIL Editor or just URL to it and your end-users may download it and use to edit translations.
4. In SIL Editor there is possible to add/delete/midify languages so users may use it for this.
5. After new language added it will be automatically recognized use 2.
Hope this helps.
mhtrozzo
Posts: 3
Joined: Tue Jul 13, 2004 12:45 am

Post by mhtrozzo »

Thanks for responding.

I'm still trying to work this out. I created a form with 2 combo boxes, 2 labels, siLangDispatcher, and siLangRTSE (so I could use the SIL editor). I set it up to change the language of these items when changing the value in ComboBox2, which worked successfully. I then added a menu to the form, and used your code. The menu looked like this:
Languages
English
German

The original items I had put on the form translated correctly, but the dynamically created ones never changed.

I went into SIL Editor, and created a new language (Spanish).

When I set LoadOnCreate to true, the labels change, but now the items in the combo boxes do not change. In addition, the new language I entered does not appear either.

Is there something I'm missing?
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

http://www.sicomponents.com/soft/demos/ ... guages.zip
Here is the demo that performs needed task.
mhtrozzo
Posts: 3
Joined: Tue Jul 13, 2004 12:45 am

Post by mhtrozzo »

Hi,

Thanks for the demo...I have a much better understanding of it now. I just have one more question as I'm testing:

I put in another button to open a message box. In the Dialog section, I added a row called TForm1.dlg1.

I added this code to the OnClick event:

Code: Select all

procedure TForm1.Button2Click(Sender: TObject);
var
s:string;
begin
//ShowMessage('test');
siLangDispatcher1.LoadAllFromFile(siLangRTSE1.SILFile);
//s := silangrtse1.GetText('dlg1');
s := silangrtse1.GetTextOrDefault('dlg1');
showmessage(s);
end;
However, when I click the button, I just get a blank message box. Am I doing something wrong?

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

Post by isiticov »

mhtrozzo wrote:In the Dialog section, I added a row called TForm1.dlg1.
You shall add it into Strings :!: section not Dialogs.
Dialogs section contains captions from dialog boxes, like MessageDlg(), InpuBox() and so on.
Strings section contains user defined strings and strings that were translated from source code (hard-coded strings).
Hope this helps.
Post Reply