有人知道 xcode 文件“InfoPlist.strings(英文)”是什么吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14538484/
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
Does anybody know what the xcode file "InfoPlist.strings (English)" is?
提问by Tom
Does anyone know what the file InfoPlist.strings
is for? It is in Xcode 3.2. It is a Cocoa app in Applescript.
有谁知道这个文件InfoPlist.strings
是干什么用的?它在 Xcode 3.2 中。它是 Applescript 中的 Cocoa 应用程序。
回答by Anoop Vaidya
An information property list file is a structured text file that contains essential configuration information for a bundled executable. The file itself is typically encoded using the Unicode UTF-8 encoding and the contents are structured using XML. The root XML node is a dictionary, whose contents are a set of keys and values describing different aspects of the bundle. The system uses these keys and values to obtain information about your app and how it is configured. As a result, all bundled executables (plug-ins, frameworks, and apps) are expected to have an information property list file.
By convention, the name of an information property list file is Info.plist.
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.
For example, the TextEdit app has several keys that are displayed in the Finder and thus should be localized. Suppose your information property list file defines the following keys:
CFBundleDisplayName TextEdit NSHumanReadableCopyright Copyright ?? 1995-2009, Apple Inc.,All Rights Reserved. The French localization for TextEdit then includes the following strings in the InfoPlist.strings file of its Contents/Resources/French.lproj directory:
CFBundleDisplayName = "TextEdit"; NSHumanReadableCopyright = "Copyright ? 1995-2009 Apple Inc.\nTous droits réservés.";
信息属性列表文件是一种结构化文本文件,其中包含捆绑可执行文件的基本配置信息。文件本身通常使用 Unicode UTF-8 编码进行编码,内容使用 XML 进行结构化。根 XML 节点是一个字典,其内容是一组描述包不同方面的键和值。系统使用这些键和值来获取有关您的应用程序及其配置方式的信息。因此,所有捆绑的可执行文件(插件、框架和应用程序)都应该有一个信息属性列表文件。
按照惯例,信息属性列表文件的名称是 Info.plist。
本地化的值不存储在 Info.plist 文件本身中。相反,您将特定本地化的值存储在名为 InfoPlist.strings 的字符串文件中。您将此文件放在用于存储相同本地化的其他资源的相同语言特定项目目录中。InfoPlist.strings 文件的内容是您想要本地化的各个键和适当翻译的值。在 Info.plist 文件中查找键值的例程将用户的语言首选项考虑在内,并在存在时返回键的本地化版本(来自相应的 InfoPlist.strings 文件)。如果密钥的本地化版本不存在,则例程将返回存储在 Info.plist 文件中的值。
例如,TextEdit 应用程序有几个键显示在 Finder 中,因此应该进行本地化。假设您的信息属性列表文件定义了以下键:
CFBundleDisplayName TextEdit NSHumanReadableCopyright 版权所有 ?? 1995-2009,苹果公司,保留所有权利。TextEdit 的法语本地化然后在其 Contents/Resources/French.lproj 目录的 InfoPlist.strings 文件中包含以下字符串:
CFBundleDisplayName = "文本编辑"; NSHumanReadableCopyright = "Copyright ? 1995-2009 Apple Inc.\nTous droits réservés。";
From developer.Apple.com