Language reporting "es" on "en" device?

I’m using system.getPreference( "locale", "language" ) to get the device language in an app and it seems like it can report the wrong language.

Has anybody seen something like this?

Getting it this way seems to work though…

local systemLanguage = system.getPreference( "ui", "language" ) or "en-US"
systemLanguage = systemLanguage:sub(1,2) -- another way to get the language

FYI…

-- Print the operating system's read-only preferences

print ( system.getPreference( "ui" , "language" ) ) -- Print the UI (device) language, i.e. "en-US"

print ( system.getPreference( "locale" , "country" ) ) -- Print the locale country, i.e. "US"

print ( system.getPreference( "locale" , "identifier" ) ) -- Print the locale language identifier, i.e. "en_US"

print ( system.getPreference( "locale" , "language" ) ) -- Print the locale language code, i.e. "en"

That’s my issue. print ( system.getPreference( "locale" , "language" ) ) prints “es” on a device that should be “en”

print ( system.getPreference( "ui" , "language" ) ) prints “en-US” on the same device.

Can’t tell if it’s a setting on my phone, or a Solar2D bug.

@ponywolf - I found this reference on the Oracle website: https://docs.oracle.com/cd/E19455-01/806-0169/6j9hsml2f/index.html

  1. A locale can be composed of both a base language, the country (territory) of use, and possibly codeset (which is usually assumed). For example, German is de, an abbreviation for Deutsch, while Swiss German is de_CH, CH being an abbreviation for Confederation Helvetica. This allows for specific differences by country, such as currency units notation.

  2. What this means is that if I were to buy a device in one country, but use it in a different country with a different language, there will be differences. For example, I often see UK devices that pay for purchases in USD. How can that happen? The locale is different from the country of origin, it seems to me.

Good luck!

1 Like