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]
returns @[@"es"]
. This is even though [[NSBundle mainBundle] localizations]
returns an array containing both "es" and "es-419".
However, [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"]
returns an array containing "es-MX".
And then the following expression:
[NSBundle preferredLocalizationsFromArray:@[@"es-419", @"es"]
forPreferences:@[@"es-MX"]]
returns @[@"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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With