現在のロケール(en、 fr、ja など)を取得するには、IFMXLocaleService.GetCurrentLangIDを使用します。
/// <summary>
/// 現在のロケールを返します
/// </summary>
function GetLang: string;
var
LocaleService: IFMXLocaleService;
begin
Result := '';
if TPlatformServices.Current.SupportsPlatformService(IFMXLocaleService, IInterface(LocaleService)) then
begin
Result := LocaleService.GetCurrentLangID;
end;
end;
IFMXLocaleService.GetCurrentLangIDが返す値は、OSによって異なるようです。
例えば日本語OSの場合、jaを返すOSとjpを返すOSがあります。
- Windows 8.1 => ja
- Windows 10 => ja
- OSX 10.9.5 => ja
- Android 5.1 => jp
- Android 4.4.2 => jp
- iOS 8.2 => ja