Recent

Author Topic: Get Language OS  (Read 20417 times)

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Get Language OS
« Reply #15 on: October 03, 2016, 08:33:27 pm »
Often programmers want to use p.3 (message translation), but uses p.1 to determine the language.
At least one other sane person that walks around on this earth :D

CM630

  • Hero Member
  • *****
  • Posts: 1436
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Get Language OS
« Reply #16 on: December 25, 2023, 06:19:38 pm »
Trying to solve some issues of improperly detected OS Language in Win.

GetLanguageIDs; does not work. I change the display language of Windows, but GetLanguageIDs keeps showing the same value, maybe the language of the OS when installed.

Registry HKCU\Control Panel\Desktop\PreferredUILanguages seems to indicate the real display language.

Is there a bug, or that is what
GetLanguageIDs is expected to do?

Also: How did the Lazarus forum succeed to create such a font mess in my post?
« Last Edit: December 25, 2023, 06:22:17 pm by CM630 »
Лазар 4,0 32 bit (sometimes 64 bit); FPC3,2,2

jamie

  • Hero Member
  • *****
  • Posts: 6991
Re: Get Language OS
« Reply #17 on: December 25, 2023, 06:44:02 pm »
https://learn.microsoft.com/en-us/windows/win32/intl/national-language-support-functions

Pick one.

Note:
  Many of these require Vista or later.
Also:
  Most likely WideString.

The only true wisdom is knowing you know nothing

jwdietrich

  • Hero Member
  • *****
  • Posts: 1260
    • formatio reticularis
Re: Get Language OS
« Reply #18 on: May 06, 2025, 07:12:43 am »
It has the advantage to also support OS X, e.g. macOS.

Try replacing your Mac code with this:

{IFDEF DARWIN}
  fbl := NSLocale.currentLocale.localeIdentifier.UTF8String;
{$ENDIF}

On newer versions of macOS the code should be replaced by:

{IFDEF DARWIN}
  fbl := NSStringToString(NSLocale.currentLocale.preferredLanguages.objectAtIndex(0).description);
{$ENDIF}
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 4.0.0 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

 

TinyPortal © 2005-2018