xcode 如何指定本地化的 Info.plist 文件的路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43227132/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:53:02  来源:igfitidea点击:

How to specify the path of localized Info.plist file

iosiphonexcodelocalizationinfo.plist

提问by Whirlwind

I had to localize Privacy - Camera Usage Description key located in Info.plist. So what I did, is that I've localized it through the File Inspector. What happened is that Info.plist is moved to the Base.lproj. That is fine. Then, again inside of File Inspector, Localization section, I checked two more languages.

我必须本地化位于 Info.plist 中的 Privacy - Camera Usage Description 键。所以我所做的是,我已经通过文件检查器对其进行了本地化。发生的事情是 Info.plist 被移动到 Base.lproj。那没关系。然后,再次在文件检查器的本地化部分中,我检查了另外两种语言。

By doing this, additional Info.plist files are added into appropriate .lproj directories. So after I have added desired translations I run the project, but Xcode throw an error which says that path of Info.plist is wrong. That make sense because Info.plist is not at the same location anymore. So I've gone into Project Navigator, Build Settings section, and found a key that says Info.plist Fileand set its value to something like this:

通过这样做,额外的 Info.plist 文件被添加到适当的 .lproj 目录中。因此,在我添加了所需的翻译后,我运行了该项目,但 Xcode 抛出一个错误,指出 Info.plist 的路径是错误的。这是有道理的,因为 Info.plist 不再位于同一位置。所以我进入了 Project Navigator 的 Build Settings 部分,找到了一个键,上面写着Info.plist File并将其值设置为如下所示:

MyProjectName/Base.lproj/Info.plist

MyProjectName/Base.lproj/Info.plist

Because the Info.plist file exists at that path, I was able to build/run an app, but still, it loads only the translation for the base language (english).

因为 Info.plist 文件存在于该路径中,所以我能够构建/运行应用程序,但它仍然只加载基本语言(英语)的翻译。

So, how should I specify the path of a localized Info.plist file ?

那么,我应该如何指定本地化的 Info.plist 文件的路径?

采纳答案by Fitzgerald Muiseroux

You should use an InfoPlist.string file. here is a related issue.

您应该使用 InfoPlist.string 文件。这是一个相关的问题。

How to localise a string inside the iOS info.plist file?

如何本地化 iOS info.plist 文件中的字符串?