Bundle preferred languages mechanism

Hi there, I’m curious to understand how the system determines which language to use for an app.

The system is currently set to en-IN (English - India).

My app supports the following languages:

  • en (the default development language)
  • en-GB (United Kingdom)
  • en-IE (Ireland)
  • en-US (United States)

When I run the app, the Bundle.main.preferredLanguages returns [„en-GB“, „en“], which causes the app to be set to en-GB. However, when the app doesn’t support the preferred system language, I would expect it to default to the en language. Surprisingly, this is not the case.

This behavior is precisely described in Technical Note TN2418. Unfortunately, there’s no explanation provided. Is this behavior related to the CLDR Linguistic Distance?

I also attempted to replace the default development language en with en-001 (English - world), but it had no effect.

Thanks for the post, love localization but definitely not in that team nor I’m an expert, hope someone in that team jumps into the thread to provide some pointers here.

I was looking at this years ago. When iOS/macOS tries to resolve a language, it doesn't just look for an exact match and then immediately give up and use your default development language. The development region (en) is the last resort. Instead, the system uses a linguistic fallback tree to find the closest possible match among the languages your app actually supports.

When a trying into my device and I set to for example something I don’t have en-IE, the system's internal fallback resolution path looks like this:

  1. en-IEDoes the app have Ireland English? No.
  2. en-GB (Does the app have British English? Yes.) I have that one set.

Because your app includes en-GB, the system stops at step 2. It determines that en-GB will provide a much better localized experience.

Changing your default development language to en-001 (World English) didn't change the behavior because the system never reached the default development language and you don’t have that?

If you specifically want users in India to see your base en localization instead of en-GB, you cannot rely on the system fallback. You have to explicitly tell the system what to do in my experience.

But hope someone I the localization team can jump here and provide us an idea what happens when you trying to select a default even when you do not have one.

Albert
  Worldwide Developer Relations.

When a trying into my device and I set to for example something I don’t have en-IE, the system's internal fallback resolution path looks like this:

  1. en-IEDoes the app have Ireland English? No.
  2. en-GB (Does the app have British English? Yes.) I have that one set.

Because your app includes en-GB, the system stops at step 2. It determines that en-GB will provide a much better localized experience.

This is exactly right. The system for choosing which language to show in the UI is somewhat complex, taking into account the user's preferred languages, the languages supported by the app itself, and language fallbacks. The language fallbacks also evolve as support for new languages is added to the operating system (and very occasionally over time, if feedback is given that specific fallback languages don't feel right).

And just FYI, how iOS determines the language for your app is documented in Q&A QA1828. The format of the Q&A isn't updated, but the content is still valid.

Regarding the fallback, the Q&A stops at mentioning that "iOS will try to fall back to a more generic language before giving up," which, to my understanding, is quite similar to CLDR Linguistic Distance.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Bundle preferred languages mechanism
 
 
Q