某些 iOS 控件具有 Apple 内置的本地化字符串。 “完成”、“编辑”、“后退”栏按钮项是一些示例。有没有办法访问这些字符串?
我正在制作一个带有标准“删除”或“取消”选项的 UIActionSheet,就像您在“通讯录”应用中删除联系人一样。
有没有办法在代码中引用这些字符串?如果没有,我至少可以在某个地方获取这些字符串(比如从 Apple 应用程序的资源中提取它们)?它将节省额外的本地化工作并确保与平台的一致性。
最佳答案
如果 iOS 类似于 Mac OS,则每个应用程序都有自己的 Localizable.strings 文件。 在每个字符串文件中,您都有所有这些小字符串,如完成、编辑、取消等。
这些是我从 Finder.app 的英文 Localizable.string 文件中复制的一些字符串:
<key>AL1</key>
<string>Cancel</string>
<key>AL4</key>
<string>OK</string>
<key>AL9</key>
<string>Don’t Save</string>
<key>FF24</key>
<string>Save</string>
<key>U32</key>
<string>Yes</string>
<key>U33</key>
<string>No</string>
你明白了。每个小字符串都在每个应用程序中本地化。
这个来自 iTunes.app。
/* ===== Ask User Strings ===== */
"23987.001" = "Yes";
"23987.002" = "No";
"23987.003" = "OK";
"23987.004" = "Cancel";
"23987.005" = "Ignore";
"23987.006" = "Quit";
"23987.007" = "Don’t Quit";
"23987.008" = "Apply";
"23987.009" = "Don’t Apply";
"23987.010" = "Later";
"23987.011" = "Don’t Save";
"23987.012" = "Save";
"23987.013" = "Stop";
"23987.014" = "Continue";
"23987.015" = "Delete";
"23987.016" = "Remove";
"23987.017" = "Replace";
"23987.018" = "Don’t Replace";
"23987.019" = "Do not ask me again";
看起来有点结构化。虽然可能不允许复制他们的文件 ;-)
安answer in apples devforum来自 Apple Developer Relations 的 Quinn (eskimo1)。
Some UI elements are automatically localised for you. For example, the artwork on a UIBarButtonItem. However, there's no supported way to get to the strings like "OK" and "Cancel" as they are used in a UIActionSheet. They should, however, be trivial for your localiser to cope with.
虽然2岁了。但是较新的线程具有相同的结果。无法获取这些字符串。
关于iphone - 您能否以编程方式访问 Cocoa Touch 中的标准本地化字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9200396/