CFLocaleCopyCurrent returns the value of CFBundleDevelopmentRegion in iOS 11

Originator:jake.petroules
Number:rdar://34581827 Date Originated:September 21 2017, 2:44 PM
Status:Reported Resolved:
Product:iOS + SDK Product Version:iOS 11 15A372
Classification:Bug Reproducible:Always
 
Area:
Core Foundation

Summary:
CFLocaleCopyCurrent() will return the value of the application's CFBundleDevelopmentRegion Info.plist key if all of the following conditions are true:
- CFBundleDevelopmentRegion is present in the Info.plist
- The CFBundleDevelopmentRegion language is in the list of preferred languages on the iOS device, but isn't the first one
- There are no localized resources (i.e. no .lproj directory) in the app for the first preferred locale

This differs from iOS 10 where the presence of the CFBundleDevelopmentRegion key had no effect.

There are logical arguments for both. The previous iOS 10 behavior made sense, because that's what the language was actually set to. However, the new iOS 11 behavior makes sense, because if there are no localized resources for the most preferred language, a fallback can be expected.

Therefore, we aren't sure if this is a bug/regression, or an intentional change in behavior.

Note that if the CFBundleDevelopmentRegion key is not present at all, CFLocaleCopyCurrent() always returns the first preferred locale as it did in iOS 10.

Steps to Reproduce:
Assume that:
- English is the "development language" on the Mac (resulting in CFBundleDevelopmentRegion = English)
- The iOS device region/language is set to German/Germany
- The iOS device preferred languages is set to German/Germany, English/US

Create a new application in Xcode and add some code to log the identifier of a CFLocale object obtained via CFLocaleCopyCurrent(). Deploy and run the application on an iOS device.

Expected Results:
CFLocaleCopyCurrent() returns German (like it did in iOS 10)

Actual Results:
CFLocaleCopyCurrent() returns English

Version/Build:
iOS 11 15A372

Configuration:
macOS 10.12.6 16G29, Xcode 9 9A235

Comments

This issue behaves as intended based on the following: This is an intentional change. Here’s the explanation: In iOS 11 and macOS High Sierra, the notion of “current locale” has changed such that, instead of always returning a locale that corresponds to the first language in Locale.preferredLanguages, it will instead match the language corresponding to Bundle.main.preferred. This is to ensure that dates, times, numbers, and other localized content that is driven by the locale is shown in a language consistent with the localization that the app is launched in. This new behavior will only take effect if Locale.preferredLanguages contains more than 1 language. Please update your bug report to let us know if this is still an issue for you.

By jake.petroules at Oct. 13, 2017, 10:41 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!