iphone – 您可以通过编程方式访问Cocoa Touch中的标准本地化字符串吗?

一些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";

看起来有点结构化。复制他们的文件可能是不允许的;-)

来自苹果开发者关系公司的Quinn(eskimo1)的answer in apples devforum

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岁。但是较新的线程具有相同的结果。没有办法得到这些字符串。

翻译自:https://stackoverflow.com/questions/9200396/can-you-programmatically-get-access-to-the-standard-localised-strings-in-cocoa-t

转载注明原文:iphone – 您可以通过编程方式访问Cocoa Touch中的标准本地化字符串吗?