Sign in Join

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

Mailing lists / lazarus / 2011-12

German localization in Lazarus app

5 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

fred f

Hi guyz,

I have compiled and use Lazarus with German language, but e.g. the buttons in message dialogs are still Yes, No, Cancel instead of German Ja, Nein, Abbrechen, ...

What should I set up to get everything in German even exceptions, ...

Thanx.

ff.

Reply by email

Michael Fuchs
to fred f
fred f wrote 7 lines
Hi guyz, I have compiled and use Lazarus with German language, but e.g. the buttons in message dialogs are still Yes, No, Cancel instead of German Ja, Nein, Abbrechen, ... What should I set up to get everything in German even exceptions, ...

For the dialogs under windows, I have a little (and very ugly) hack:

--------->8--------->8--------->8--------->8--------->8--------->8--
{$IFDEF WINDOWS}
{$R ekgnet.rc}
// HACK: For using german descriptions in Messagebox
procedure HookResourceString(rs: PResStringRec; newStr: PChar);
var
   oldprotect: DWORD;
begin
   VirtualProtect(rs, SizeOf(rs^), PAGE_EXECUTE_READWRITE, @oldProtect);
   rs^ := newStr;
   VirtualProtect(rs, SizeOf(rs^), oldProtect, @oldProtect);
end;
{$ENDIF}
begin
   Application.Title := 'project1';
   Application.Initialize;
   Application.CreateForm(TForm1, Form1);
   {$IFDEF WINDOWS}
   HookResourceString(@rsMbYes, 'Ja');
   HookResourceString(@rsMbNo, 'Nein');
   {$ENDIF}
   Application.Run;
end.

--------->8--------->8--------->8--------->8--------->8--------->8--

hth
Michael

Reply by email

Sven Barth
to Michael Fuchs
Michael Fuchs wrote 37 lines
Am 19.12.2011 09:38, schrieb fred f: > Hi guyz, > > I have compiled and use Lazarus with German language, but e.g. the > buttons in message dialogs are still Yes, No, Cancel instead of German > Ja, Nein, Abbrechen, ... > > What should I set up to get everything in German even exceptions, ... For the dialogs under windows, I have a little (and very ugly) hack: --------->8--------->8--------->8--------->8--------->8--------->8-- {$IFDEF WINDOWS} {$R ekgnet.rc} // HACK: For using german descriptions in Messagebox procedure HookResourceString(rs: PResStringRec; newStr: PChar); var oldprotect: DWORD; begin VirtualProtect(rs, SizeOf(rs^), PAGE_EXECUTE_READWRITE, @oldProtect); rs^ := newStr; VirtualProtect(rs, SizeOf(rs^), oldProtect, @oldProtect); end; {$ENDIF} begin Application.Title := 'project1'; Application.Initialize; Application.CreateForm(TForm1, Form1); {$IFDEF WINDOWS} HookResourceString(@rsMbYes, 'Ja'); HookResourceString(@rsMbNo, 'Nein'); {$ENDIF} Application.Run; end.

One can do that less "ugly" (and portable):

=== source begin ===

// aName is in format "unit.identifier"
function TranslateLCLStrConsts(aName, aValue: AnsiString; aHash: Longint;
   aArg: Pointer): AnsiString;
var
   name: String;
begin
   name := LowerCase(aName);
   // if you have a dotted unit name you will need to adjust this
   Delete(name, 1, Length('lclstrconsts') + 1);
   if name = 'rsmbyes' then
     Result := '&Ja'
   else
   if name = 'rsmbno' then
     Result := '&Nein'
   else
   if name = 'rsmbok' then
     Result := '&OK'
   else
   if name = 'rsmbcancel' then
     Result := 'Abbrechen'
   else
   if name = 'rsmbabort' then
     Result := 'Abbrechen'
   else
   if name = 'rsmbretry' then
     Result := '&Wiederholen'
   else
   if name = 'rsmbignore' then
     Result := '&Ignorieren'
   else
   if name = 'rsmball' then
     Result := '&Alle'
   else
   if name = 'rsmbnotoall' then
     Result := 'Nein f?r Alle'
   else
   if name = 'rsmbyestoall' then
     Result := 'Ja f?r Alle'
   else
   if name = 'rsmbhelp' then
     Result := '&Hilfe'
   else
   if name = 'rsmbclose' then
     Result := '&Schlie?en'
   else
   if name = 'rsmbopen' then
     Result := '&?ffnen'
   else
   if name = 'rsmbsave' then
     Result := 'Speichern'
   else
   if name = 'rsmbunlock' then
     Result := 'Entriegeln'
   else
   if name = 'rsmtwarning' then
     Result := 'Warnung'
   else
   if name = 'rsmterror' then
     Result := 'Fehler'
   else
   if name = 'rsmtinformation' then
     Result := 'Information'
   else
   if name = 'rsmtconfirmation' then
     Result := 'Best?tigung'
   else
   if name = 'rsmtauthentication' then
     Result := 'Authentifizierung'
   else
   if name = 'rsmtcustom' then
     Result := 'Benutzerdefiniert'
   else
     Result := aValue;
end;
// somewhere (e.g. main program file):
SetUnitResourceStrings('LCLStrConsts', @TranslateLCLStrConsts, Nil);

=== source end ===

See also:
http://www.freepascal.org/docs-html/rtl/objpas/setunitresourcestrings.html

Regards,
Sven

Reply by email

Mattias Gaertner
to Sven Barth
Show quoted text 9 lines
Am 19.12.2011 14:45, schrieb Michael Fuchs: > Am 19.12.2011 09:38, schrieb fred f: >> Hi guyz, >> >> I have compiled and use Lazarus with German language, but e.g. the >> buttons in message dialogs are still Yes, No, Cancel instead of German >> Ja, Nein, Abbrechen, ... >> >> What should I set up to get everything in German even exceptions, ...

See
http://wiki.lazarus.freepascal.org/Translations_/_i18n_/_localizations_for_programs#Translating_at_start_of_program

Mattias

Reply by email

Sven Barth
to Mattias Gaertner
Mattias Gaertner wrote 15 lines
On Tue, 20 Dec 2011 10:17:00 +0100 Sven Barth wrote: > Am 19.12.2011 14:45, schrieb Michael Fuchs: >> Am 19.12.2011 09:38, schrieb fred f: >>> Hi guyz, >>> >>> I have compiled and use Lazarus with German language, but e.g. the >>> buttons in message dialogs are still Yes, No, Cancel instead of German >>> Ja, Nein, Abbrechen, ... >>> >>> What should I set up to get everything in German even exceptions, ... See http://wiki.lazarus.freepascal.org/Translations_/_i18n_/_localizations_for_programs#Translating_at_start_of_program

Regarding
http://wiki.lazarus.freepascal.org/Translations_/_i18n_/_localizations_for_programs#Compiling_po_files_into_the_executable : Can one also use FPC 2.4.0+ resources for that?

Regards,
Sven

Reply by email