mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 19:39:17 +02:00
Examples, translation: fix compilation on Linux, comment out old BiDi workaround, patch by wp, bug #25541
git-svn-id: trunk@43731 -
This commit is contained in:
parent
ce870413b0
commit
b4f110b22d
@ -23,7 +23,9 @@ type
|
|||||||
protected
|
protected
|
||||||
procedure UpdateTranslation(ALang: String); virtual;
|
procedure UpdateTranslation(ALang: String); virtual;
|
||||||
public
|
public
|
||||||
|
(* Activate for Lazarus version older than 1.2
|
||||||
procedure FlipChildren(AllLevels: Boolean); override;
|
procedure FlipChildren(AllLevels: Boolean); override;
|
||||||
|
*)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -35,9 +37,11 @@ procedure UpdateBiDiMode(ALang: String);
|
|||||||
procedure UpdateFormatSettings(ALang: String); // Windows only!
|
procedure UpdateFormatSettings(ALang: String); // Windows only!
|
||||||
|
|
||||||
// Utility functions for Windows only
|
// Utility functions for Windows only
|
||||||
|
{$IFDEF MSWINDOWS}
|
||||||
function GetFullLangCodeFromLCID(LCID: Integer): String;
|
function GetFullLangCodeFromLCID(LCID: Integer): String;
|
||||||
function GetLangCodeFromLCID(LCID: Integer): String;
|
function GetLangCodeFromLCID(LCID: Integer): String;
|
||||||
function GetLCIDFromLangCode(ALang: String): Integer;
|
function GetLCIDFromLangCode(ALang: String): Integer;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -53,6 +57,7 @@ uses
|
|||||||
|
|
||||||
{ Local procedures }
|
{ Local procedures }
|
||||||
|
|
||||||
|
{$IFDEF MSWINDOWS}
|
||||||
function GetLocaleStr(LCID, LT: Longint; const Def: string): ShortString;
|
function GetLocaleStr(LCID, LT: Longint; const Def: string): ShortString;
|
||||||
// borrowed from SysUtils
|
// borrowed from SysUtils
|
||||||
var
|
var
|
||||||
@ -65,20 +70,19 @@ begin
|
|||||||
else
|
else
|
||||||
Result := Def;
|
Result := Def;
|
||||||
end;
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
|
||||||
{ Utility procedures }
|
{ Utility procedures - Windows-only }
|
||||||
|
|
||||||
|
{$IFDEF MSWINDOWS}
|
||||||
{ This is how to convert LCID to language code like 'de', 'en', etc.
|
{ This is how to convert LCID to language code like 'de', 'en', etc.
|
||||||
Works only for Windows.
|
Works only for Windows.
|
||||||
See also: GetFullLangCode}
|
See also: GetFullLangCode}
|
||||||
function GetLangCodeFromLCID(LCID: Integer): String;
|
function GetLangCodeFromLCID(LCID: Integer): String;
|
||||||
{$IFDEF MSWINDOWS}
|
|
||||||
var
|
var
|
||||||
language: PAnsiChar;
|
language: PAnsiChar;
|
||||||
{$ENDIF}
|
|
||||||
begin
|
begin
|
||||||
{$IFDEF MSWINDOWS}
|
|
||||||
language := StrAlloc(255);
|
language := StrAlloc(255);
|
||||||
try
|
try
|
||||||
GetLocaleInfoA(LCID, LOCALE_SISO639LANGNAME, PAnsiChar(language), 255);
|
GetLocaleInfoA(LCID, LOCALE_SISO639LANGNAME, PAnsiChar(language), 255);
|
||||||
@ -86,9 +90,7 @@ begin
|
|||||||
finally
|
finally
|
||||||
StrDispose(language);
|
StrDispose(language);
|
||||||
end;
|
end;
|
||||||
{$ELSE}
|
|
||||||
Result := '';
|
Result := '';
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ This is how to convert LCID to language code like 'de_DE', 'en_US', etc.
|
{ This is how to convert LCID to language code like 'de_DE', 'en_US', etc.
|
||||||
@ -98,12 +100,9 @@ end;
|
|||||||
or http://delphi.cjcsoft.net/viewthread.php?tid=45881
|
or http://delphi.cjcsoft.net/viewthread.php?tid=45881
|
||||||
or http://msdn.microsoft.com/en-us/library/dd318101%28VS.85%29.aspx }
|
or http://msdn.microsoft.com/en-us/library/dd318101%28VS.85%29.aspx }
|
||||||
function GetFullLangCodeFromLCID(LCID: Integer): String;
|
function GetFullLangCodeFromLCID(LCID: Integer): String;
|
||||||
{$IFDEF MSWINDOWS}
|
|
||||||
var
|
var
|
||||||
language, country: PAnsiChar;
|
language, country: PAnsiChar;
|
||||||
{$ENDIF}
|
|
||||||
begin
|
begin
|
||||||
{$IFDEF MSWINDOWS}
|
|
||||||
language := StrAlloc(255);
|
language := StrAlloc(255);
|
||||||
country := StrAlloc(255);
|
country := StrAlloc(255);
|
||||||
try
|
try
|
||||||
@ -114,24 +113,12 @@ begin
|
|||||||
StrDispose(country);
|
StrDispose(country);
|
||||||
StrDispose(language);
|
StrDispose(language);
|
||||||
end;
|
end;
|
||||||
{$ELSE}
|
|
||||||
Result := '';
|
|
||||||
{$ENDIF}
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure UpdateBiDiMode(ALang: String);
|
|
||||||
begin
|
|
||||||
if Application.IsRTLLang(ALang) then
|
|
||||||
Application.BidiMode := bdRightToLeft
|
|
||||||
else
|
|
||||||
Application.BiDiMode := bdLeftToRight;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ This function determines the LCID from the language code.
|
{ This function determines the LCID from the language code.
|
||||||
Works only for Windows. }
|
Works only for Windows. }
|
||||||
function GetLCIDFromLangCode(ALang: String): Integer;
|
function GetLCIDFromLangCode(ALang: String): Integer;
|
||||||
begin
|
begin
|
||||||
{$IFDEF MSWINDOWS}
|
|
||||||
case lowercase(ALang) of
|
case lowercase(ALang) of
|
||||||
'ar' : Result := $0401; // Arabic
|
'ar' : Result := $0401; // Arabic
|
||||||
'bg' : Result := $0403; // Bulgarian
|
'bg' : Result := $0403; // Bulgarian
|
||||||
@ -155,8 +142,8 @@ begin
|
|||||||
// http://www.science.co.il/Language/Locale-codes.asp
|
// http://www.science.co.il/Language/Locale-codes.asp
|
||||||
else raise Exception.CreateFmt('Language "%s" not supported. Please add to GetLCIDFromLangCode.',[ALang]);
|
else raise Exception.CreateFmt('Language "%s" not supported. Please add to GetLCIDFromLangCode.',[ALang]);
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
{ SetDefaultSettings changes the FormatSettings according to the selected
|
{ SetDefaultSettings changes the FormatSettings according to the selected
|
||||||
language. Unfortunately there is not platform-independent way to do this
|
language. Unfortunately there is not platform-independent way to do this
|
||||||
@ -182,14 +169,21 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure UpdateBiDiMode(ALang: String);
|
||||||
|
begin
|
||||||
|
if Application.IsRTLLang(ALang) then
|
||||||
|
Application.BidiMode := bdRightToLeft
|
||||||
|
else
|
||||||
|
Application.BiDiMode := bdLeftToRight;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TLocalizedForm }
|
{ TLocalizedForm }
|
||||||
|
|
||||||
{ FlipChildren does not work correctly with TRadioGroup and TCheckGroup. This
|
{ This is a workaround for older version of Lazarus where FlipChildren does
|
||||||
work-around by-passes these classes for the FlipChildren action.
|
not work correctly with TRadioGroup and TCheckGroup. Activate this code
|
||||||
A patch has been submitted to bugtracker fixing this issue permanently
|
for versions older than Lazarus 1.2 }
|
||||||
(http://mantis.freepascal.org/view.php?id=25408). This method is no longer
|
(*
|
||||||
needed once that patch has been included in Lazarus. }
|
|
||||||
procedure TLocalizedForm.FlipChildren(AllLevels: Boolean);
|
procedure TLocalizedForm.FlipChildren(AllLevels: Boolean);
|
||||||
|
|
||||||
procedure _DoFlipChildren(AControl: TWinControl);
|
procedure _DoFlipChildren(AControl: TWinControl);
|
||||||
@ -213,6 +207,7 @@ begin
|
|||||||
_DoFlipChildren(Self);
|
_DoFlipChildren(Self);
|
||||||
inherited FlipChildren(false);
|
inherited FlipChildren(false);
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
|
|
||||||
{ Each inherited form will have to put code in procedure
|
{ Each inherited form will have to put code in procedure
|
||||||
UpdateTranslation(ALang: String) to translate strings not
|
UpdateTranslation(ALang: String) to translate strings not
|
||||||
|
Loading…
Reference in New Issue
Block a user