LoadLangFromStrings
http://docwiki.embarcadero.com/Libraries/Berlin/en/FMX.Types.TLang
http://blog.csdn.net/pcplayer/article/details/78152471
procedure TForm7.Button1Click(Sender: TObject); var list: TStringList; begin list := TStringList.Create; list.LoadFromFile('cn.txt'); LoadLangFromStrings(list); list.Free; end; procedure TForm7.Button2Click(Sender: TObject); var list: TStringList; begin list := TStringList.Create; list.LoadFromFile('en.txt'); LoadLangFromStrings(list); list.Free; end;
cn.txt
Button1=开始
Button2=结束
RadioButton1=性别
en.txt
Button1=start
Button2=end
RadioButton1=option
//没找到下文的出处和原作者。暂时记录.
// uses FMX.Platform{$IFDEF MSWINDOWS}, WinAPi.Windows{$ENDIF}; {$R *.fmx} // 以下这个函数,获取当前操作系统的语言设置。 比如 Windows 底下,语言为中文,返回 Zh // 这个函数支持各种操作系统。 end; 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;