xcode 本地化 Info.plist 后构建错误

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

Build error after I localized Info.plist

iosobjective-cxcodeswiftlocalization

提问by Cherif

I localized Info.plist :

我本地化 Info.plist :

enter image description here

在此处输入图片说明

And I got this build error :

我得到了这个构建错误:

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

Actually there are now two Info.plist files :

实际上现在有两个 Info.plist 文件:

fr.lproj/Info.plist
Base.lproj/Info.plist

How to localize the Info.plist path ?

如何本地化 Info.plist 路径?

回答by ncerezo

Roll back those changes, add a InfoPlist.strings file to your project, localize it and then add the needed keys to it. For example:

回滚这些更改,将 InfoPlist.strings 文件添加到您的项目,对其进行本地化,然后向其中添加所需的键。例如:

"CFBundleDisplayName" = "App display name";
"CFBundleName" = "App bundle name";

回答by Costas Bakoulias

To 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 文件!