Xcode 找不到本地化的 info.plist

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

Xcode cannot locate localized info.plist

iosxcodelocalizationinfo.plist

提问by ohho

After adding a few Localizations:

添加一些本地化后:

enter image description here

在此处输入图片说明

and localized the (AppName)-info.plistfile:

并本地化(AppName)-info.plist文件:

enter image description here

在此处输入图片说明

and checked Bundle Resources (also tried to remove Go-info.plist from the Copy Resources Bundlelist:

并检查了捆绑资源(还尝试从Copy Resources Bundle列表中删除 Go-info.plist :

enter image description here

在此处输入图片说明

and the file property:

和文件属性:

enter image description here

在此处输入图片说明

Xcode (4.6.3) give an error:

Xcode (4.6.3) 报错:

error: could not read data from '.../Go/Go/Go-Info.plist': The file “Go-Info.plist” couldn't be opened because there is no such file.

错误:无法从“.../Go/Go/Go-Info.plist”读取数据:无法打开文件“Go-Info.plist”,因为没有这样的文件。

It looks like Xcode ignores the localization folder in the path. It tried to find the info.plist as:

看起来 Xcode 忽略了路径中的本地化文件夹。它试图找到 info.plist 为:

.../Go/Go/Go-Info.plist

instead of:

代替:

.../Go/Go/(Localization)/Go-Info.plist

How can I fix it?

我该如何解决?

回答by Toploulou

I think Info.plistcan not be localized. If you want to localize your application Name, you should localize the InfoPlist.stringsfile and use those keys :

我认为Info.plist不能本地化。如果您想本地化您的应用程序名称,您应该本地化InfoPlist.strings文件并使用这些键:

"CFBundleDisplayName" = "AppName";
"CFBundleName" = "AppName";

回答by Costas Bakoulias

Step by step localized Info.plist:

逐步本地化的 Info.plist:

  1. Find in the x-code the folder Resources (is placed in root)
  2. Select the folder Resources
  3. Then press the main menu File->New->File...
  4. Select in section "Resource" Strings File and press Next
  5. Then in Save As field write InfoPlist ONLY ("I" capital and "P" capital)
  6. Then press Create
  7. Then select the file InfoPlist.strings that created in Resources folder and press in the right menu the button "Localize"
  8. Then you Select the Project from the Project Navigator and select the The project from project list
  9. In the info tab at the bottom you can as many as language you want (There is in section Localizations)
  10. The language you can see in Resources Folder
  11. To localize the values ("key") from info.plist file you can open with a text editor and get all the keys you want to localize
  12. You write any key as the example in any InfoPlist.strings like the above example
  1. 在 x-code 中找到文件夹 Resources(放在 root 中)
  2. 选择文件夹资源
  3. 然后按主菜单 File->New->File...
  4. 在“资源”字符串文件部分中选择,然后按下一步
  5. 然后在“另存为”字段中仅写入 InfoPlist(“I”大写和“P”大写)
  6. 然后按创建
  7. 然后选择在 Resources 文件夹中创建的文件 InfoPlist.strings 并在右侧菜单中按“Localize”按钮
  8. 然后从项目导航器中选择项目并从项目列表中选择项目
  9. 在底部的信息选项卡中,您可以使用任意数量的语言(在本地化部分中有)
  10. 您可以在资源文件夹中看到的语言
  11. 要本地化 info.plist 文件中的值(“键”),您可以使用文本编辑器打开并获取要本地化的所有键
  12. 您可以在任何 InfoPlist.strings 中编写任何键作为示例,如上例

"NSLocationAlwaysAndWhenInUseUsageDescription"="blabla";

"NSLocationAlwaysAndWhenInUseUsageDescription"="blabla";

"NSLocationAlwaysUsageDescription"="blabla2";

"NSLocationAlwaysUsageDescription"="blabla2";

That's all work and you have localize your info.plist file!

这就是全部工作,您已经本地化了 info.plist 文件!