I needed (for a project I am working on) to obtain the default language for the operation system. Preferable it should be in “human” format like “English” instead of “En-US”.
The AI lead me to strange paths. In the end it tuned out to be quite easy so I created these two function (now part of my Delphi LightSaber) library. It works on all platforms!
// Returns the language of the operating system in this format: "English (United States)" function GetSystemLanguageName: string; begin VAR Locale:= TLanguages.UserDefaultLocale; Result := TLanguages.Create.NameFromLocaleID[Locale]; end; // Returns the language of the operating system in this format: "English" function GetSystemLanguageShortName: string; var FullName: string; P: Integer; begin FullName := GetSystemLanguageName; P := Pos('(', FullName); if P > 0 then Result := Trim(Copy(FullName, 1, P - 1)) else Result := FullName; end;