Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-08

MessageDLG and localization Win/Linux

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

John Landmesser

Hi,

same lazarus app, compiled on Windows XP, german localization:

Code:
MessageDlg('Title', 'Text', mtInformation, [ mbCancel, mbYes, mbNo], 0);

You get buttons Captions 'Yes' and 'No' until you add:

procedure TForm1.FormCreate(Sender: TObject);
    var
      PODirectory, Lang, FallbackLang: String;
   begin
       PODirectory := 'C:\lazarus\lcl\languages\';
      //PODirectory := '/home/john1/lazarus/lcl/languages/';
      GetLanguageIDs(Lang, FallbackLang); // in unit gettext
      TranslateUnitResourceStrings('LCLStrConsts', PODirectory + 'lclstrconsts.%s.po', Lang, FallbackLang);
      MessageDlg('Title', 'Text', mtInformation, [ mbCancel, mbYes, mbNo], 0);
    end;

The same app compiled on my Debain Sid, i get
buttons Captions 'Ja' and 'Nein' even if i comment out the code above.

Isn't there a easier way to handle this problem for Win XP? I got the above solution from lazarus wiki and i thought, how to solve this the Delphi way?

John

Reply by email

Bart
to John Landmesser
John Landmesser wrote 18 lines
procedure TForm1.FormCreate(Sender: TObject); var PODirectory, Lang, FallbackLang: String; begin PODirectory := 'C:\lazarus\lcl\languages\'; //PODirectory := '/home/john1/lazarus/lcl/languages/'; GetLanguageIDs(Lang, FallbackLang); // in unit gettext TranslateUnitResourceStrings('LCLStrConsts', PODirectory + 'lclstrconsts.%s.po', Lang, FallbackLang); MessageDlg('Title', 'Text', mtInformation, [ mbCancel, mbYes, mbNo], 0); end; The same app compiled on my Debain Sid, i get buttons Captions 'Ja' and 'Nein' even if i comment out the code above.

I think it's WM magic, replacing buttoncaptions Yes, No etc to locale.

Isn't there a easier way to handle this problem for Win XP? I got the above solution from lazarus wiki and i thought, how to solve this the Delphi way?

And what would be the Delphi way?

If (like me) you are only interested in translating into one language (German I guess) it maybe easier to include the po-file as a Lazarus resource in a unit and do the translation from there. If you do this in the initialization section of this unit, then you only have to include the unit in the uses clause to get German translations of the LCL resourcestrings.
You might periodically have to refesh the resouce if the po-file changes)

I have a code example for this (the code example on the wiki doesn't work for me).

Bart

Reply by email

leledumbo
to John Landmesser: same lazarus app, compiled on Windows XP, german localization: Code: MessageDlg('Title',…
The same app compiled on my Debain Sid, i get buttons Captions 'Ja' and 'Nein' even if i comment out the code above.

AFAIK your system locale is the default, either you have to provide language choice options or hardcode the language you want to translator functions.

View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-MessageDLG-and-localization-Win-Linux-tp3248991p3249298.html Sent from the Free Pascal - Lazarus mailing list .

Reply by email