[Lazarus] MessageDLG and localization Win/Linux

Bart bartjunk64 at gmail.com
Fri Aug 12 14:31:56 CEST 2011


On 8/12/11, John Landmesser <johnml at online.de> wrote:
> 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




More information about the Lazarus mailing list