Application.BiDiMode - should be based on application or system language? lazarus / 31-LCL ---------------------------------------------------------------------- dezlov · 2015-06-13 19:47 Users of my applications started to report "a bug", where GUI is displayed in RightToLeft mode while the interface was in English (or any other non-RTL language). Initially, I did not consider this to be a bug, so I kept suggesting users to change their system locale to non-RTL language. However, the more I thought about it the more it seemed like a bug. Now, I am almost convinced that it is plain wrong to use system locale to determine BiDiMode of an application, especially when BiDiMode of system locale and application's language are different. Few examples to demonstrate: System=Hebrew & Application=English => Application.BidiMode=bdRightToLeft (English in RTL)System=English & Application=Hebrew => Application.BidiMode=bdLeftToRight (Hebrew in LTR) This is automatically applied by LCL in TApplication.Create, at initialization section of Forms.pp unit: Code: [Select]  {$ifndef wince}// remove ifdef when gettext is fixed   LCLGetLanguageIDs(LangDefault, LangFallback);   if LangDefault <> '' then     FBidiMode := Direction(LangDefault)   else     FBidiMode := Direction(LangFallback);   {$else}     FBidiMode := bdLeftToRight;   {$endif} I have also found a Bug Report #0022044: Wrong Initial value for Application.BidiMode http://bugs.freepascal.org/view.php?id=22044 I would like to get opinions of users, application developers and Lazarus developers: Can we disable/remove/move setting of Application.BidiMode based on system language in LCL?Should Application.BidiMode be always initialized to bdLeftToRight by default?Should Application.BidiMode be a part of Project Settings?Should setting appropriate BidiMode be a responsibility of the developer of each application?Should i18n/l10n procedures be able to automatically set Application.BidiMode according the loaded language? ---------------------------------------------------------------------- Zaher · 2015-06-13 20:10 It is bug for me and wrong behavior. I opened that topic in the past in message list here http://permalink.gmane.org/gmane.comp.ide.lazarus.general/56590 http://permalink.gmane.org/gmane.comp.ide.lazarus.general/62835 ---------------------------------------------------------------------- JuhaManninen · 2015-06-13 21:50 We would need a maintainer for BiDi related stuff. Zaher, would you be the maintainer? ---------------------------------------------------------------------- Zaher · 2015-06-13 22:17 @JuhaManninen You know, I sent many patches that accepted the past for bidimode, so i feel i am already maintaining it, but if the problem conflicted with other opinions , for that we need who judge for it. ---------------------------------------------------------------------- JuhaManninen · 2015-06-13 23:39 Quote from: Zaher on June 14, 2015, 12:17:16 amYou know, I sent many patches that accepted the past for bidimode, so i feel i am already maintaining it, but if the problem conflicted with other opinions , for that we need who judge for it. Yes, I know your work in this area. Thanks about it. Maintainer is the person who judges cases with conflicting opinions. I think you could take that role more. None of Lazarus core developers uses RTL language natively. It means there is not enough knowledge or understanding for BiDi issues, and not even motivation for it because everybody basically "scratches his own itch". The "itch" for BiDi comes with RTL languages. ---------------------------------------------------------------------- Zaher · 2015-06-13 23:49 Ok, i will start with this bug, and i will send a patch for it in the bug trucker, it is one line btw. ---------------------------------------------------------------------- dezlov · 2015-06-14 11:25 So what's the plan? Shall we move that BidiMode setting code out of TApplication.Create and into a separate method, e.g. TApplication.ApplySystemBiDiMode. Code: [Select]procedure TApplication.ApplySystemBidiMode; var   LangDefault, LangFallback: String; begin   {$ifndef wince} // remove ifdef when gettext is fixed   LazGetLanguageIDs(LangDefault, LangFallback);   if LangDefault <> '' then     SetBidiMode(Direction(LangDefault))   else     SetBidiMode(Direction(LangFallback));   {$endif} end; Application developers can then call this method if they wish to apply system's BiDIMode. While in TApplication.Create just set the default: Code: [Select]const   DefaultApplicationBiDiMode: TBiDiMode = bdLeftToRight; constructor TApplication.Create; begin   ...   FBidiMode := DefaultApplicationBiDiMode;   ... end; Edit: Patch attached in http://bugs.freepascal.org/view.php?id=22044 ---------------------------------------------------------------------- Zaher · 2015-06-14 12:56 I think we don't not need DefaultApplicationBiDiMode because developer can set it in the project lpr before application.initialize Code: [Select]    Application.BidiMode := bdLeftToRight;     Application.Initialize; but for ApplySystemBidiMode i am not sure but if we keep it in the application.create but change the fallback language to default bidimode (LeftToRight) not take it from LangFallback Code: [Select]  LazGetLanguageIDs(LangDefault, LangFallback);   if LangDefault <> '' then     FBidiMode := Direction(LangDefault)   else     FBidiMode := bdLeftToRight; ---------------------------------------------------------------------- Zaher · 2015-06-14 13:13 This not work, ignore Code: [Select]  LazGetLanguageIDs(LangDefault, LangFallback);   if LangDefault <> '' then     FBidiMode := Direction(LangDefault)   else     FBidiMode := bdLeftToRight; We need to fix Lazarus IDE too when choose RightToLeft Language ---------------------------------------------------------------------- Zaher · 2015-06-14 13:40 Choosing Right to left depend on Developer 1 - Application is English (default) 2 - Application is RTL     Application.BidiMode := bdLeftToRight;     Application.Initialize; 3 - Application is multi language, so RTL should take it from the language that choosed from the user of that application, not from the system     developer can choose the language at first time runing from the system, so ApplySystemBidiMode  not useful here.