I ran into this issue where the app name in the home screen is shown in the wrong language. This only happens when none of the user's preferred languages is supported by the app. I have tested this in Xcode 8 and iOS 10 using multiple projects both in the simulator and a real device.
When none of the user's preferred languages is supported by the app, the interface language is displayed using the app's development region (CFBundleDevelopmentRegion
) as described in this document. So far so good. However, the app name in the home screen does not honor this and it seems to pick English or the first .lproj
folder alphabetically (if English is not present).
Let's say my app supports the following languages:
And my device settings look like this:
The following statement:
[NSLocale preferredLanguages]
returns the expected result:
<__NSArrayM 0x79da6b30>(
en
)
And this other statement:
[[NSBundle mainBundle] preferredLocalizations]
also returns the expected result:
<__NSArrayM 0x79716630>(
zh
)
However, the app name in the home screen uses the wrong localization:
Am I missing something? Have any of you run into this issue?
Steps to reproduce:
- Create a new iOS project.
- Go to project settings -> Info -> Localizations and add a second language e.g. Japanese.
- Add a CFBundleDisplayName to the Info.plist file.
- Change the CFBundleDevelopmentRegion to zh_CN.
- Create new InfoPlist.strings file. In the inspector tab, under Localization click the "Localize..." button. Select to move it to the Chinese lproj folder from the dropdown.
- In the inspector tab, under Localization check the Japanese checkbox.
- Edit the InfoPlist.strings files and add "CFBundleDisplayName" = "Chinese"; or "CFBundleDisplayName" = "Japanese"; respectively.
- Run the app in the simulator or a real device with its language & region settings set to something different than Chinese or Japanese e.g. English & U.S.
Expected Results:
The user interface and app name are expected to be displayed in the app development language (Chinese in the example).
Observed Results:
The user interface is shown in the app development language (Chinese in the example) while the app name is shown in Japanese.