NSLocale returning wrong value in iOS 11

后端 未结 1 669
后悔当初
后悔当初 2021-01-05 02:53

Starting from iOS 11.0, the following code returns \"de_US\" instead of \"en_US\":

// => Returns \"de_US\"
NSString *regionCode = [[NSLoc         


        
相关标签:
1条回答
  • 2021-01-05 03:25

    Found it!

    It's a change behaviour starting from iOS 11.

    Under iOS 11, [NSLocale currentLocale] only returns languages supported by your app’s localizations. If your app only supports English (as the base localization), then no matter what language the user selects on the device, currentLocale will always return English.

    Under iOS 10 and earlier, currentLocale would directly represent the user’s chosen language and region, regardless of what localizations your app supports.

    More information here:

    • https://jaanus.com/ios-11-changes-localized-date-handling/

    • Maddy's stack overflow answer: https://stackoverflow.com/a/46206511/1226963

    0 讨论(0)
提交回复
热议问题