8
votes

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

// => Returns "de_US"
NSString *regionCode = [[NSLocale currentLocale] objectForKey:NSLocaleIdentifier];
NSLog(@"Region code: %@", regionCode);

Below iOS 11, it returns "en_US".

My device has for language and region English / United States. Preferred languages (despite I do not use them in my code) are in order:

  1. English
  2. Deutsch
  3. French

Is it a known issue of iOS 11? Has the API changed?

1
Does this happen on a device or in the simulator? And furthermore: the app has an English localization? - mschmidt
It happens on a device: iPhone 6 Plus. App has only one localization: "Localizable.strings" file in Xcode target. Values are in German in this file, but I didn't specified it was German file in Xcode. So I'm wondering where this "de_" comes from. - hico

1 Answers

16
votes

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: