Skip to main content
Participant
November 11, 2011
Question

How to get the locale/region of the device?

  • November 11, 2011
  • 1 reply
  • 1652 views

I want to retrieve the locale/region being used on the user's mobile device (doing this on iOS at the moment) and seem to be having difficulty figuring this out.

I need to be able to distinguish between en_US, en_UK, en_CA etc.

Capabilities.language & Capabilities.languages just seem to return the language "en" and not the locale/region being used for the device.

I've also tried using

var defaultLocale:LocaleID = new LocaleID(LocalID.DEFAULT);

trace(defaultlLocale.getLanguage + "_" + defaultLocale.getRegion());

But this just results in an output of "i-default_" (invalid language setting and empty region setting).

Any ideas on what API calls I need to be using, or what I'm doing wrong?

Thanks in advance

This topic has been closed for replies.

1 reply

Participant
November 11, 2011

Well it looks like if you go into the devices Settings->General->International->Language you can set the preferred language to "British English".

This will then cause Capabilities.languages to return "en-GB" for the first element of the array (the prefferred language). Not sure why it doesn't use proper locale/region codes, but that's another discussion.

The remaining issue is that there is no device setting for "Canadian English", so this doesn't completely solve my problem.

iOS devices do also let you set the "Region Format" which does have a "Canada" setting. I'm guessing that I could use this as a work around if we have access to the "Region Format" data through some AIR API. Does anyone know if we have access to the "Region Format" information on iOS devices and how we'd access that information?

Thanks.

edmunditor
Participating Frequently
June 26, 2013

If anyone is looking for an answer to get the language with the regional setting, it looks like the method described in this post works:

http://forums.adobe.com/message/5398764