user102008 user102008 - 1 year ago 71
iOS Question

"Español (México)" language setting uses "Spanish" strings instead of "Spanish (Latin America)" strings

Our iOS project has localized strings for both "Spanish" (es.lproj) and "Spanish (Latin America)" (es-419.lproj), as created from within Xcode.

However, on the iPhone (U.S., latest iOS 7), the only language options for Spanish are "Español" and "Español (México)", no "Latin America". And when you select "Español (México)", it uses the "Spanish" strings from our app, not the "Spanish (Latin America)" strings, as one would expect.

On further investigation,

[[NSBundle mainBundle] preferredLocalizations]
. This is even though
[[NSBundle mainBundle] localizations]
returns an array containing both "es" and "es-419".

[[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"]
returns an array containing "es-MX".

And then the following expression:

[NSBundle preferredLocalizationsFromArray:@[@"es-419", @"es"]


Why would Xcode give us "Spanish (Latin America)" localization, when it is not used when you actually select the only Latin American Spanish option on the phone?

Answer Source

This has changed in iOS 9 and 10, and should work correctly. If your localization is not present in your project, though, it will pick up the Base localization if it exists. There is only one Base available; if your user has selected "es-MX" as his phone language and you only have "es", it will chose string from the Base localization and NOT from the "es" base Spanish translation.

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