Daniele B Daniele B - 1 year ago 82
iOS Question

iOS Localization: simulator behaves differently than device

I have set up 2 languages in my app:

  • English (development language)

  • Italian

enter image description here

I am expecting that in case the device is set to a language different than Italian, the app would come up in English.

However I noticed an inconsistency, between simulator and device:

  • If I set the simulator to Spanish, the app comes up in English

  • If I set the device to Spanish, the app comes up in Italian

how can I make sure the app comes up in English when the device language is set to Spanish?

Answer Source

I believe this inconsistency is due to the preferred language order in Setting App -> General -> Language & Region. Your iPhone device is likely to have ordered Italian with higher preference.

As stated in Apple's documentation (https://developer.apple.com/library/ios/qa/qa1828/_index.html)

To determine the language for your app, iOS considers not only the order of the user language preferences (in General > Language & Region of the Settings application) but also the localizations your app declares it supports. Here is the detailed process:

  1. iOS first looks up your user's most preferred language, which is the first entry in their language preferences.

  2. It proceeds to check if that language is supported by your app. iOS searches your app bundle for an .lproj folder matching the preferred language. If the folder exists, iOS infers that your app has been localized for that language and chooses it for your app. Otherwise, iOS selects the next language in the user language preferences, then repeats the above check.

    The dialect support in iOS may slightly change the above behavior. If your user's preferred language is a regional variant that is not supported by your app, iOS will try to fall back to a more generic language before giving up. For example, if your user's preferred language is British English and your app bundle doesn't contain an en-GB.lproj or en_GB.lproj folder, iOS then searches your bundle for an en.lproj folder and chooses English for your app if the folder exists.

  3. If none of the user’s preferred languages are supported by your app, iOS chooses the language matching your app's development region (CFBundleDevelopmentRegion).

In Summary,

a. For user who knows both Italian and English, it will display in their preference.

b. If they only know one of the two, it will display the correct one.

c. If they don't know both, you should set CFBundleDevelopmentRegion in your info.plist to select English.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download