Category Archives: Apps

Apps worth to annouce to the world

iOS9 localization and Internationalization

Language Identifiers in iOS 9

With iOS 9, the results returned by NSLocale.preferredLanguages() can differ from previous releases. In iOS 8 and earlier, only certain language, script, and region combinations were returned by this API. However, in iOS 9, more combinations of language, script, and region are permitted.

For example, when a user has configured their iOS device with language set to English and region set to India, NSLocale.preferredLanguages() will now return [ "en-IN" ], instead of [ "en" ]. This allows for smarter language fallbacks; for this user, if an app doesn’t support en-IN as a localization, but does support en-GB, the fallback mechanism will select en-GB instead of en.

These implicit fallbacks are not always obvious from the language identifier; they are driven by locale data used by NSBundle’s resource-loading mechanism. Trying to handle language identifiers manually, or performing string comparisons on them, will lead to problems. Instead, rely on NSBundle APIs when loading resources or matching language identifiers to an available set of languages.