iOS localization is broken with the upgrade iOs 9 + Xcode 7

痞子三分冷 提交于 2019-12-10 03:45:44

问题


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

1

And of the device used for testing

Thanks in advance


回答1:


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.




回答2:


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




回答3:


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



来源:https://stackoverflow.com/questions/32710913/ios-localization-is-broken-with-the-upgrade-ios-9-xcode-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!