7

I localized my app in Italian and English, using the Localizable.strings file and the NSLocalizedString macro. I also enabled base localization. Everything works fine in the simulator and on devices with iOS 8, but on iOS 9 the app is always in english, even on devices with the italian language selected as default in the iPhone settings. Does iOS 9 changes something with localization?

Here's a screenshot of the Xcode localization settings
http://i.imgur.com/xc20yjj.png1

And of the device used for testing
http://i.imgur.com/QCjn52u.png

Thanks in advance

gotqn
  • 42,737
  • 46
  • 157
  • 243
LorenzOliveto
  • 7,796
  • 1
  • 20
  • 47
  • 1
    What language is your scheme running in? Select your app title in the breadcrumb in Xcode (next to the simulator selector) -> Edit Scheme... -> Run -> Options -> Application Language? – wakachamo Sep 22 '15 at 11:11
  • The Application Language is settled to the System Language. Everything seems ok in fact I don't know where to look at – LorenzOliveto Sep 22 '15 at 12:20
  • Looks like English has 4 files localised, but Italian only has 2–could that be the reason? Which files are localised in your project? – wakachamo Sep 22 '15 at 12:36
  • I removed the english localization because it was a copy of the base but the app is still in english. I will investigate this strange problem in the next days. It seems that it ignores the default language in the settings and load the base strings – LorenzOliveto Sep 22 '15 at 14:31

4 Answers4

9

Solved, the "problem" was the key "Localization native development region" in the info.plist file. It was setted to Italy, so when the app was running in a device with the Italian language as default it was showing the Base localization version of the strings (the English version). Changing the value to United States solved the issue.

LorenzOliveto
  • 7,796
  • 1
  • 20
  • 47
  • I met the same problem. But I change the value to 'Unite States' did not help. My 2nd language is Chinese Traditional. – Ducky Chen Nov 04 '15 at 09:36
  • However, if I change the 'Region' setting of the iOS device to 'Unite States', I can see Chinese on my app then. Why does the 'Region' setting matter? – Ducky Chen Nov 04 '15 at 09:38
  • Your base strings file is in english or in chinese? – LorenzOliveto Nov 04 '15 at 10:18
  • My base string file is in english – Ducky Chen Nov 04 '15 at 10:26
  • I'm sorry but I can't help, this is a very strange behavior – LorenzOliveto Nov 04 '15 at 10:33
  • I checked the return value of [NSLocale preferredLanguages], it shows 3 objects.. 'zh-TW', 'en-TW', 'zh-Hans-TW'. The first one supposed to be 'zh-Hant-TW'. It will return 'zh-Hant' in iOS 8.x. My device language is Traditional Chinese', and my region is 'Taiwan' – Ducky Chen Nov 04 '15 at 10:57
2

I have another solution, just remove the key 'Localizations' in info.plist. It works for my case.

Ducky Chen
  • 369
  • 2
  • 5
  • This worked for me. Project-Info-Localization and info.plist-Localization was different in my case. – Minsu Dec 24 '15 at 08:50
1

I've found a workaround. The root cause of this problem is Apple changed the "Language Identifiers" in iOS 9, please refer this.

Since NSLocalizedString() (and variants thereof) access the "AppleLanguages" key in NSUserDefaults to determine what the user's settings for preferred languages are. I forced NSLocalizedString to use a specific language with is noted as their old Language Identifiers in older iOS versions once I found their Language ID is in new format. In another word, I made a mapping of "AppleLanguages" key value.

To do this, please refer to: How to force NSLocalizedString to use a specific language

I think Apple did a very bad job in compatibility!!

Community
  • 1
  • 1
Ducky Chen
  • 369
  • 2
  • 5
  • Note that I cannot find a way to add a localized resource with code "zh-TW", I can only add "zh", "zh-Hant" or "zh-Hant-TW" only. Not sure if it is a bug of apple. – Ducky Chen Nov 04 '15 at 15:01
0

So I found out you have add the languages you want the app to support. You have to manually select it to localization.