View Issue Details

IDProjectCategoryView StatusLast Update
0025541LazarusPatchpublic2014-01-18 14:50
Reporterwp Assigned ToMaxim Ganetsky  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformi86OSUbuntu 
Product Version1.2.0RC2 
Fixed in Version1.2.0 
Summary0025541: Translations example does not compile on Ubuntu
DescriptionThe example project "translations" added recently to lazarus/examples does not compile on Ubuntu because some conditional defines are missing to exclude all windows-only code in unit "localizedforms".

The attached patch sets the defines correctly. With these changes, the demo runs on Windows and Linux.

The patch also comments out a workaround for right-to-left issues with TRadiogroup and TCheckgroup which have been fixed by 0025408.
TagsNo tags attached.
Fixed in Revision43731, 43740
LazTarget-
WidgetsetGTK 2
Attached Files

Activities

wp

2014-01-15 23:16

developer  

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

Maxim Ganetsky

2014-01-15 23:31

developer   ~0072472

Applied, thanks.

BTW, I noticed that 'Several items' checkgroup items are not translated. Is this normal?

wp

2014-01-15 23:50

developer   ~0072473

Strange. It is translated here on Windows (1.2RC2, trunk) and Ubuntu (trunk)

Maxim Ganetsky

2014-01-16 00:18

developer  

transl-checkgroup.PNG (12,398 bytes)   
transl-checkgroup.PNG (12,398 bytes)   

Maxim Ganetsky

2014-01-16 00:18

developer   ~0072478

See attached screenshot. Lazarus 1.3 r43729 FPC 2.6.3 Windows XP.

wp

2014-01-16 00:25

developer   ~0072479

Ah sorry - I was looking at the caption... Yes, this is intentional to demonstrate that DefaultTranslator does not translate the items of a CheckGroup automatically. There is a note on that at the end of unit2.

Maxim Ganetsky

2014-01-16 00:58

developer   ~0072480

Ah, OK. Your patch is scheduled for merging to 1.2.

wp

2014-01-18 00:55

developer   ~0072525

Sorry to bother you again: You say that the patch is scheduled for 1.2, but according to the header it will be fixed in 1.4. Which one is correct?

Maxim Ganetsky

2014-01-18 01:14

developer   ~0072526

It was merged in r43740.

Issue History

Date Modified Username Field Change
2014-01-15 23:16 wp New Issue
2014-01-15 23:16 wp File Added: localizedforms.pas.patch
2014-01-15 23:31 Maxim Ganetsky Fixed in Revision => 43731
2014-01-15 23:31 Maxim Ganetsky LazTarget => -
2014-01-15 23:31 Maxim Ganetsky Note Added: 0072472
2014-01-15 23:31 Maxim Ganetsky Status new => resolved
2014-01-15 23:31 Maxim Ganetsky Fixed in Version => 1.4
2014-01-15 23:31 Maxim Ganetsky Resolution open => fixed
2014-01-15 23:31 Maxim Ganetsky Assigned To => Maxim Ganetsky
2014-01-15 23:50 wp Note Added: 0072473
2014-01-16 00:18 Maxim Ganetsky File Added: transl-checkgroup.PNG
2014-01-16 00:18 Maxim Ganetsky Note Added: 0072478
2014-01-16 00:25 wp Note Added: 0072479
2014-01-16 00:58 Maxim Ganetsky Note Added: 0072480
2014-01-18 00:55 wp Note Added: 0072525
2014-01-18 01:14 Maxim Ganetsky Fixed in Revision 43731 => 43731, 43740
2014-01-18 01:14 Maxim Ganetsky Note Added: 0072526
2014-01-18 01:14 Maxim Ganetsky Fixed in Version 1.4 => 1.2.0
2014-01-18 14:50 wp Status resolved => closed