简体   繁体   中英

iOS localization is broken with the upgrade iOs 9 + Xcode 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.png 1

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

Thanks in advance

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.

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

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!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM