中国开发网: 论坛: Delphi/BCB: 贴子 1001203
pcplayer:获得当前操作系统的语言
uses FMX.Platform;

function GetOSLangID: String;
{$IFDEF MACOS}
var
Languages: NSArray;
begin
Languages := TNSLocale.OCClass.preferredLanguages;
Result := TNSString.Wrap(Languages.objectAtIndex(0)).UTF8String;
{$ENDIF}
{$IFDEF ANDROID}
var
LocServ: IFMXLocaleService;
begin
if TPlatformServices.Current.SupportsPlatformService(IFMXLocaleService, IInterface(LocServ)) then
Result := LocServ.GetCurrentLangID;
{$ENDIF}
{$IFDEF MSWINDOWS}
var
buffer: MarshaledString;
UserLCID: LCID;
BufLen: Integer;
begin
// defaults
UserLCID := GetUserDefaultLCID;
BufLen := GetLocaleInfo(UserLCID, LOCALE_SISO639LANGNAME, nil, 0);
buffer := StrAlloc(BufLen);
if GetLocaleInfo(UserLCID, LOCALE_SISO639LANGNAME, buffer, BufLen) <> 0 then
Result := buffer
else
Result := 'en';
StrDispose(buffer);
{$ENDIF}
end;

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录