XCode - 多个目标,多个*国际化*名称?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1807377/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
XCode - Multiple targets, Multiple *internationalized* names?
提问by Kris Jenkins
I've got an internationalized iPhone project. In the various ${lang}.lproj/InfoPlist.strings
files I've got a single key, CFBundleName = "My App Name"
.
我有一个国际化的 iPhone 项目。在各种${lang}.lproj/InfoPlist.strings
文件中,我有一个键,CFBundleName = "My App Name"
.
That's working fine for a single target, but I can't make it work for multiple targets.
这适用于单个目标,但我无法使其适用于多个目标。
I'd like to have several translated InfoPlistMyApp.strings
files for the main target, plus several InfoPlistMyAppLite.strings
files for the lite version. But I can't figure out how to set it up. The InfoPlist.strings
name seems to be set in stone, so I can't replace it dynamically.
我想要几个InfoPlistMyApp.strings
主要目标的翻译文件,以及lite 版本的几个文件。但我不知道如何设置它。这个名字似乎是一成不变的,所以我不能动态替换它。InfoPlistMyAppLite.strings
InfoPlist.strings
Any ideas?
有任何想法吗?
回答by Kris Jenkins
Turns out this is quite easy, if laborious. You can have several InfoPlist.strings, one-enabled-per-target, and they can each be internationalized, as long as each set is in a different Xcode group.
事实证明这很容易,如果费力的话。您可以有多个 InfoPlist.strings,每个目标一个启用,并且它们每个都可以国际化,只要每个集合都在不同的 Xcode 组中。
Set up a directory structure like this:
设置目录结构如下:
.../AppName/
en.lproj/InfoPlist.strings <-- Contains CFBundleDisplayName
it.lproj/InfoPlist.strings <-- ...
...
.../AppNameLite/
en.lproj/InfoPlist.strings <-- ...
it.lproj/InfoPlist.strings <-- ...
...
Import those files into Xcode groups, so it looks like this:
将这些文件导入 Xcode 组,如下所示:
Right-click "Groups & Files" (top left of Xcode) and make sure "Target Membership" is visible, then go through your targets, checking the the right set of strings is enabled for each.
右键单击“组和文件”(Xcode 的左上角)并确保“目标成员资格”可见,然后浏览您的目标,检查是否为每个目标启用了正确的字符串集。