0

I am using Delphi XE3. The default language is English and I add a language of Chinese.

THen I use the following method to detect the locale of the current application:

procedure TForm1.Button1Click(Sender: TObject);
var
   strNameBuffer : array [0..LOCALE_NAME_MAX_LENGTH-1] of WideChar;
begin
    if (LCIDToLocaleName(GetThreadLocale(), strNameBuffer, LOCALE_NAME_MAX_LENGTH, 0) = 0) then
      RaiseLastOSError
    else
      Application.MessageBox(strNameBuffer, 'Info');
end;

When I set the locale override key under HKEY_CURRENT_USER\Software\Embarcadero\Locales to "EN", then the UI will show English. But clicking the Button1 will show the current thread locale as zh-CN, why?

alancc
  • 487
  • 2
  • 24
  • 68
  • See also [GetThreadLocale returns different value than GetUserDefaultLCID?](https://stackoverflow.com/q/1767946/576719) – LU RD Dec 26 '20 at 23:13
  • @LURD, what you said is expected. Since locale override will set a different locale for the current application, may be different than the user's default locale. – alancc Dec 27 '20 at 01:08
  • Windows knows nothing about that "locale override". It's just a Delphi-specific mechanism to determine which resource DLL to load. – Olivier Dec 27 '20 at 09:19
  • @Olivier, In such a case, is there a way for the application know what is the actual locale loaded by the current application? – alancc Dec 27 '20 at 09:33
  • Maybe `FormatSettings.NormalizedLocaleName`? – Olivier Dec 27 '20 at 10:02

0 Answers0