localising goes wrong in iOS9

I have made a (development) build for my app and installed it on both my iPod5 (iOS9.0.2) and my old iPod4 (iOS6.1.6). So they have both the same build installed!

Default language of the app is english. The app is localised in dutch (my native language). The app is localised as described in https://docs.coronalabs.com/guide/distribution/localization/index.html

I have changed the language settings of both iPods to english, and all goes well. The title is in english and the language inside the app too.

On the other hand, when I change the language settings (back) to dutch something strange happens. On the old iPod4 (iOS6.1.6) everything still goes well (both title and language inside the app are dutch).

But, on the iPod5 (iOS9.0.2) things are messing up: the title is in dutch, but the language inside the app is english.

I am baffled.

Does anyone have a idea where to search for this error?

Hi @Ton B.,

Apple changed localization strings slightly in iOS 9. Our updated documentation and example is here:

https://docs.coronalabs.com/api/library/system/getPreference.html

We’re looking into possible options on making the detection of the locale more consistent/predictable across devices and OS versions, but in the meantime, you may need to parse one of the existing string values to determine what you need for the purpose you’re using it for.

Best regards,

Brent

Brent,

thanks for your reply. It really was the slightly changed localization in iOS9.

I addition to that:

I have added some lines to detect which iOS version the device has and to adapt the way the app localizes.

First, let’s presume that the language setting is english and that the regioformat is dutch.

In iOS9:

system.getPreference(“ui”, “language”) returns “en-NL”

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

In iOS8 and before:

system.getPreference(“ui”, “language”) returns “en”

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

If you want a variable having the value of the language setting:

[lua]deviceLanguage = “en”[/lua]

you have to do this in iOS8 and before:

[lua]local deviceLanguage = system.getPreference(“ui”, “language”)[/lua]

and in iOS9 (and later?):

[lua]local deviceLanguage = system.getPreference(“locale”, “language”)[/lua]

I have added the following lines. They work for me. At least until the next slight change.

[lua]local thePlatformName = system.getInfo(“platformName”)

local uiOrLocale

if thePlatformName == “iPhone OS” then

   local thePlatformVersion = system.getInfo(“platformVersion”)

   local i = 1

   while thePlatformVersion:sub(i,i) ~= “.” do

       i = i + 1

   end

   local iOSVersion = thePlatformVersion:sub(1,(i - 1))

   local iOSVersionValue = tonumber(iOSVersion)

   if iOSVersionValue < 9 then

      uiOrLocale = “ui” – for iOS8 and before

   else

      uiOrLocale = “locale” – for iOS9 (and later?)

   end

else

   uiOrLocale = “locale” – for Android

end

local deviceLanguage = system.getPreference(uiOrLocale, “language”)[/lua]

Hi @Ton B.,

Apple changed localization strings slightly in iOS 9. Our updated documentation and example is here:

https://docs.coronalabs.com/api/library/system/getPreference.html

We’re looking into possible options on making the detection of the locale more consistent/predictable across devices and OS versions, but in the meantime, you may need to parse one of the existing string values to determine what you need for the purpose you’re using it for.

Best regards,

Brent

Brent,

thanks for your reply. It really was the slightly changed localization in iOS9.

I addition to that:

I have added some lines to detect which iOS version the device has and to adapt the way the app localizes.

First, let’s presume that the language setting is english and that the regioformat is dutch.

In iOS9:

system.getPreference(“ui”, “language”) returns “en-NL”

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

In iOS8 and before:

system.getPreference(“ui”, “language”) returns “en”

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

If you want a variable having the value of the language setting:

[lua]deviceLanguage = “en”[/lua]

you have to do this in iOS8 and before:

[lua]local deviceLanguage = system.getPreference(“ui”, “language”)[/lua]

and in iOS9 (and later?):

[lua]local deviceLanguage = system.getPreference(“locale”, “language”)[/lua]

I have added the following lines. They work for me. At least until the next slight change.

[lua]local thePlatformName = system.getInfo(“platformName”)

local uiOrLocale

if thePlatformName == “iPhone OS” then

   local thePlatformVersion = system.getInfo(“platformVersion”)

   local i = 1

   while thePlatformVersion:sub(i,i) ~= “.” do

       i = i + 1

   end

   local iOSVersion = thePlatformVersion:sub(1,(i - 1))

   local iOSVersionValue = tonumber(iOSVersion)

   if iOSVersionValue < 9 then

      uiOrLocale = “ui” – for iOS8 and before

   else

      uiOrLocale = “locale” – for iOS9 (and later?)

   end

else

   uiOrLocale = “locale” – for Android

end

local deviceLanguage = system.getPreference(uiOrLocale, “language”)[/lua]