I'm trying to show a different string for Mexican Spanish than US Spanish. The app always displays the US Spanish phrase. FYI - English, French and Portuguese work fine - but they don't have locales specified.
I created the localization folder in Build Settings->Localizations by clicking the + button, and selecting Spanish (Mexico)(es-MX) and Spanish (United States)(es-US) from the "Other" menu. I then updated the phrases appropriately. In the project I see 5 Localizable.strings files, including (Spanish-Mexico) and (Spanish-United States). Similarly I see the expected folders in Finder, including es-MX and es-US.
I put some NSLog messages in application didFinishLaunchingWithOptions:
NSLog(@"preferredLocalizations=%@", [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0]);
NSLog(@"localization array=%@, count=%d", [[NSBundle mainBundle] preferredLocalizations], [[[NSBundle mainBundle] preferredLocalizations] count]);
NSLog(@"preferredLanguage = %@", [[NSLocale preferredLanguages] objectAtIndex:0]);
NSLog(@"language array=%@, count=%d", [NSLocale preferredLanguages], [[NSLocale preferredLanguages] count]);
NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
NSArray* languages = [defs objectForKey:@"AppleLanguages"];
NSString *current = [languages objectAtIndex:0];
NSLog(@"user default language=%@", current);
The output is:
2013-07-30 22:21:24.911 ecatalog[33497:907] application:didFinishLaunchingWithOptions
2013-07-30 22:21:24.918 ecatalog[33497:907] preferredLocalizations=es
2013-07-30 22:21:24.920 ecatalog[33497:907] localization array=(
es
), count=1
2013-07-30 22:21:24.922 ecatalog[33497:907] preferredLanguage = es
2013-07-30 22:21:24.924 ecatalog[33497:907] language array=(
es,
en,
fr, <snipped a bunch for brevity>
ms,
"en-GB",
ca,
hu,
vi
), count=34
2013-07-30 22:21:24.926 ecatalog[33497:907] user default language=es
The language array seems to the list of available languages on the phone, in my preferred order - i.e., if I set the phone for French, fr
will be at the top of the list.
I don't know if its related, but my project includes two 3rd party frameworks which support Spanish, but just the es.lproj variation - not es-MX.lproj or es-US.lproj.
One other "symptom" - running the app in the simulator alternates between English and whatever language I have set the simulator to.
Thanks!