简体   繁体   中英

Xcode - Changing Bundle Display Name By Language

I want my app name to be localized(English and Simplified Chinese). I localize the Info.plist in my project and added Simplified Chinese. So I have two Info.plist files now. Error occured when I build the project. "Info.plist could not be found". So I edited the path of Info.plist at Build Settings > Packaging > Info.plist File Path. Now it worked.

The problem is that at Build Settings > Packaging > Info.plist File Path , Xcode only seeks for one Info.plist. If I change the path to zh-Hans.lproj/Info.plist It would only display Chinese App Name on both English and Chinese Language Settings. And the same goes when I change it to en.lproj.

How can I set the path of the Info.plist so that xcode could recognize that there are two of them that needs to be used according to Language setting?

Or is there any better way than what I am doing?

Many Thanks!

You don't localize Info.plist itself, you put localized strings in a separate file InfoPlist.strings . Quoting Apple:

Localized values are not stored in the Info.plist file itself. Instead, you store the values for a particular localization in a strings file with the name InfoPlist.strings. You place this file in the same language-specific project directory that you use to store other resources for the same localization. The contents of the InfoPlist.strings file are the individual keys you want localized and the appropriately translated value. The routines that look up key values in the Info.plist file take the user's language preferences into account and return the localized version of the key (from the appropriate InfoPlist.strings file) when one exists. If a localized version of a key does not exist, the routines return the value stored in the Info.plist file.

In the specific case of the display name, each localized version of InfoPlist.strings would contain something like

CFBundleDisplayName = "My Cool App";

and the display name in Info.plist would be used only if it is not overridden in InfoPlist.strings .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM