Get device language

How can I detect the user’s selected language on their device?

I imagine an entry in system.getInfo() for this SO answer:

https://stackoverflow.com/a/4221416/71376

I believe that you want https://docs.coronalabs.com/api/library/system/getPreference.html

I actually looked at that doc page this morning, too.

:wacko:

I’m going to link this in your other thread…

Glad to be of assistance. Sometimes the information doesn’t sink in even if you read it once, I know that all to well. :smiley:

I want to get the default language of the device, but the default language returned by system.getPreference( “locale”, “language” )is always english (en). My device is set in “es” (Spanish).

@desarrollo8 I think you’d have better luck posting a new thread. This one is marked resolved. Also, make sure you post some code.

Something seems to have change recently in Corona with the 

system.getPreference( “locale”, “language” )

Now I only receive “en” as language instead of “es” (spanish) as I was receiving before.

Is there any bug with this?

“locale”  seems to work ok on Android but not on iOS

I use this

 if \_isAndroid then locale = system.getPreference( "locale", "language" ):upper() else locale = system.getPreference( "ui", "language" ):upper() end

Apple changed the rules on getting the device local information in iOS 12. Look at the SampleCode/HelloWorldLocalized/ sample app for the things you need to add to build.settings to get the information from iOS.

You will want to look in the latest daily builds…

Rob

I believe that you want https://docs.coronalabs.com/api/library/system/getPreference.html

I actually looked at that doc page this morning, too.

:wacko:

I’m going to link this in your other thread…

Glad to be of assistance. Sometimes the information doesn’t sink in even if you read it once, I know that all to well. :smiley:

I want to get the default language of the device, but the default language returned by system.getPreference( “locale”, “language” )is always english (en). My device is set in “es” (Spanish).

@desarrollo8 I think you’d have better luck posting a new thread. This one is marked resolved. Also, make sure you post some code.

Something seems to have change recently in Corona with the 

system.getPreference( “locale”, “language” )

Now I only receive “en” as language instead of “es” (spanish) as I was receiving before.

Is there any bug with this?

“locale”  seems to work ok on Android but not on iOS

I use this

 if \_isAndroid then locale = system.getPreference( "locale", "language" ):upper() else locale = system.getPreference( "ui", "language" ):upper() end

Apple changed the rules on getting the device local information in iOS 12. Look at the SampleCode/HelloWorldLocalized/ sample app for the things you need to add to build.settings to get the information from iOS.

You will want to look in the latest daily builds…

Rob