Detect current language on Android

Hi,

I'm using XE6 to generate an application for Android.

Could someone tell me how to detect current device language ('EN', 'FR',....)?

Thanks in advance !!
0
Benjamin
9/17/2014 1:40:40 PM
embarcadero.delphi.firemonkey 4901 articles. 4 followers. Follow

2 Replies
1470 Views

Similar Articles

[PageSpeed] 34

This is for all platforms.
{code}
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;
{code}
0
Cristian
9/17/2014 4:00:38 PM
Thank you very much!
0
Benjamin
9/19/2014 1:01:01 AM
Reply:

Similar Artilces:

What is the best current book for the Delphi language?
The last time I was heavily invested in programming in Delphi was in the version 7 days -- I was wondering what the best current book on the Delphi language is (so I can get up to date)? Diego Barros wrote: > > The last time I was heavily invested in programming in Delphi was in > the version 7 days -- I was wondering what the best current book on > the Delphi language is (so I can get up to date)? Probably Marco's book: http://www.marcocantu.com/epascal/default.htm Chris Rolliston also has a very good book: http://delphifoundations.com/ -- Nick Del...

XE5 FireMonkey for android Arabic language?
*What is the solution to the problem of writing in Arabic language -XE5 FireMonkey for android ?* isam buk wrote: > *What is the solution to the problem of writing in Arabic language -XE5 FireMonkey for android ?* > Can you be a bit more descriptive of the problem? Do you get an error? Do characters not display correctly? > {quote:title=quinn wildman wrote:}{quote} > isam buk wrote: > > *What is the solution to the problem of writing in Arabic language -XE5 FireMonkey for android ?* > > > Can you be a bit more descriptive of the problem? Do you get an...

Sys.CultureInfo not detect current Browser Language
Sys.CultureInfo.CurrentCulture is always set in en-US format.Is not correct that      (cs)  System.Threading.Thread.CurrentThread.CurrentCulture not equal to   (ajax) Sys.CultureInfo.CurrentCulture Both values need to be automatically syncronized Replacing the Sys.CultureInfo.CurrentCulture value not work. For example, adding the next javascript to set the spanish culture: <script type="text/javascript"><!--var __spanishInfo = '{"name":"es-ES","numberFormat":{"CurrencyDecimalDigits":2,"CurrencyDecimalSeparator":".","IsReadOnly":false,"Cu...

is possible to build an Android .SO with Delphi Firemonkey XE6 ? Thanks.
is possible to build an Android .SO with Delphi Firemonkey XE6 ? Thanks. > {quote:title=Aldo Lacavalla wrote:}{quote} > is possible to build an Android .SO with Delphi Firemonkey XE6 ? Thanks. Have a look in your Android output directory -- Linden "Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source" > {quote:title=Linden ROTH wrote:}{quote} > > {quote:title=Aldo Lacavalla wrote:}{quote} > > is possible to build an Android .SO with Delphi Firemonkey XE6 ? Thanks. > > > Have a look in ...

Does Delphi XE5 firemonkey work on current Samsung tablets? [Edit]
I am being told that Delphi XE5 with firemonkey will not work on the current range of Samsung tablets even if they have Android 4 is that true? If so I will be very disappointed having invested thousands of pounds and a few hundred hours to adopt the technology on the promise I can now deploy to Android mobile devices. When I run even the most simple Hello World app I simply get a black screen on my brand new Samsung tablet. I am told it only works on Android devices with a ARMv7 CPU supporting NEON instruction sets. If this is the case developers need to know that I have been told today ...

Android C demo program to Firemonkey Delphi (Will Pay)
I have a C demo program for the Android platform that I need to convert to Firemonkey and Delphi XE5. This demo logic is written in pure C, and reads one of 5 canned barcodes. Page39a contains those barcodes. The goal is to scan those codes and react accordingly. This conversion will serve as a learning process for me. I am willing to pay for this conversion if need be. Thanking you all in advance and I look forward to any recommendations. Andy http://www.odesk.com/ has developers for hire. Thanks Eli. I will check it out. Andy On Thu, 29 May 2014 06:18:43 -0700, Eli...

Ann: TsiLang Components Suite v7.1! (Multilanguage solution for Delphi and C++Builder with full FireMonkey support including Android and iOS)
Hello, We're glad to announce the release of TsiLang Components Suite 7.1! Simple and powerful localization solution for software developers. It's virtually impossible to find popular software that would not be translated (localized) into multiple languages. In fact, even niche and second-tier developers localize their products to increase international sales. Unfortunately, the process of software localizations is both time consuming and very expensive. Luckily, developers who use Delphi, or C++Builder platform can use TsiLang Components Suite to localize their software...

Ann: TsiLang Components Suite v7.1! (Multilanguage solution for Delphi and C++Builder with full FireMonkey support including Android and iOS)
Hello, We're glad to announce the release of TsiLang Components Suite 7.1! Simple and powerful localization solution for software developers. It's virtually impossible to find popular software that would not be translated (localized) into multiple languages. In fact, even niche and second-tier developers localize their products to increase international sales. Unfortunately, the process of software localizations is both time consuming and very expensive. Luckily, developers who use Delphi, or C++Builder platform can use TsiLang Components Suite to localize their software...

Language like Delphi 6 or Delphi 7
Hi I like to make application what will connect to web services(SOAP or REST) and send data to server via HTTPS. I have previous experience with Delphi 6 and Delphi 7.I know that language in Delphi 2009 is changed. Which is the last Delhi(Delphi 2005, Delphi 2009) what have the languages like Delphi 6 or Delphi 7. Additional ,which edition(home,professional ,architect) I should use if i like to achieve my task? Pero perov wrote: > I know that language in Delphi 2009 is changed. That is not true. > Which is the last Delhi(Delphi 2005, Delphi 2009) what > have the lan...

Does Delphi XE5 on Android work with the Android emulator? [Edit]
I find that even a hello-world app exactly like the one that David I outlines (add a button, one line of code, set button text) will not run on the Android Emulator configured out of the box. First, after installing the Rad Studio XE5 trial, I followed David I's steps exactly, and the emulator would not even start. Then I clicked Android SDK manager, updated it, and clicked run-without-debugging. It asked me if I wanted to start the emulator this time so I did. Now the Firemonkey app will not start up the emulator, and while it does appear to start debugging, the emulator scree...

[Android] TImage3D can not display on Android (Delphi XE7)
TImage3D can not display any image on Android,Only display black color in TImage3D. But it can be displayed in the windows platform. Android Phone: Nexus5 Version: Delphi XE7 Test step: Create a new Blank project of Multi-Device Application and add a 3D Form , Add a TImage3D control and set property "Bitmap" with any Image/Picuture (etc: PNG or JPG picture),run on Android phone, then you can found the android form display the Image3D with full black color ,not display any picture. But it can be displayed in the windows platform. There is a bug in XE7 so that no material or im...

Language detection?
Anyone got a language detection plugin? I get a lot of spam slipping through in spanish, and I'd like to just whack it on the head. Matt. Hi On 5. nov. 2009, at 16.33, Matt Sergeant wrote: > Anyone got a language detection plugin? I get a lot of spam slipping > through in spanish, and I'd like to just whack it on the head. There's http://spamassassin.apache.org/full/3.1.x/doc/Mail_SpamAssassin_Plugin_TextCat.html but not sure if that's what you want. -Johan On Sat, 7 Nov 2009, Johan Almqvist wrote: > Hi > > On 5. nov. 2009, at 1...

What language current?
Are both the suite AND FF/TB written in XUL now? ...

Delphi for Android
If this is not the right forum, please direct me to the right one. I want to write a simple application for android. Is it possible? I have bought Delphi XE2 and downloaded Andoid sdk. Is there any site to guide me step by step for this job? Can I do the same task with Free Pascal, or even better with Lazarus? Regarding FPC or Lazarus, I need it for highschool teaching purposes. Thanks a lot in advance, Dimitris Dimitris Koutsourelis wrote: > If this is not the right forum, please direct me to the right one. > I want to write a simple application for android. Is it possible?...

Web resources about - Detect current language on Android - embarcadero.delphi.firemonkey

Language - Wikipedia, the free encyclopedia
Language is the human capacity for acquiring and using complex systems of communication , and a language is any specific example of such a system. ...

The Eero Programming Language
Interesting new programming language from Andy Arvanitis: Eero is a fully binary- and header-compatible dialect of Objective-C, implemented ...

App used to teach foreign languages
The Federal Government trials an app program for preschoolers to help teach one of five languages which includes Mandarin, Japanese, Indonesian, ...

NACO premieres work inspired by Rita Joe's poem of language lost
The world premiere of I Lost My Talk — Spirit Prevails takes place tonight at the National Arts Centre. The multidisciplinary work is inspired ...

Quebec restaurant in trouble with language police over grilled cheese
A grilled cheese restaurant in the Quebec City area is in trouble with the province’s language police for using the English words “grilled cheese” ...

Swift is quickly rising in popularity as a developer language … but how much is Apple using Swift?
The TIOBE index uses search engine rankings to track popularity of programming languages. In January, Swift overtook Objective-C to become the ...

Speaking their language
Speaking their language by digby The success of the conservative movement's message discipline is never better illustrated than when liberals ...

Cameron Toughens Language Requirements for U.K. Immigrants
Prime Minister David Cameron said immigrants to the U.K. who can’t show their language skills are improving may face deportation, as part of ...

MSNBC Guest Accuses GOP Candidates of Calling Obama Racial Language — ‘Boy’
MSNBC Guest Accuses GOP Candidates of Calling Obama Racial Language - 'Boy'

Learn any of these 16 programming languages and you'll always have a job
... capitalist Marc Andreessen famously declared. Someone has to write that software. Why not you? There are thousands of programming languages, ...

Resources last updated: 1/19/2016 10:49:55 PM