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

标签 iphone ios localization

一些 iOS 控件具有 Apple 内置的本地化字符串。 “完成”、“编辑”、“返回”栏按钮项目是一些示例。有没有办法访问这些字符串?

我正在制作一个带有标准“删除”或“取消”选项的 UIActionSheet,就像您在“通讯录”应用中删除联系人时一样。

有没有办法在代码中引用这些字符串?如果没有,是否有地方至少可以获取这些字符串(例如从 Apple 应用程序的资源中提取它们)?它将节省额外的本地化工作,并确保与平台的一致性。

最佳答案

如果 iOS 就像 Mac OS 一样,每个应用程序都带有自己的 Localized.strings 文件。 在每个字符串文件中,您都有所有这些小字符串,例如“完成”、“编辑”、“取消”等。

这些是我从 Finder.app 的英文 Localized.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 开发者关系部的 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/32769262/

相关文章:

ios - 在没有 NSString 的情况下使用带有 NSData 的 Swift 字符串

ios - 如何正确调整 UILabel 内容的大小? (查看帖子内的图片以便更好地理解)

ios - 制作一个停在 spritekit 中的物体上的激光

iphone - iOS - 成员引用是一个指针?

iphone - MFMailComposeViewController 的 "No mail accounts"警报问题 - SDK 3.0 与 SDK 4.0

ASP.NET - 给定编码 .resx 中的无效字符

language-agnostic - 是否有用于区域设置解析的标准算法?

android - 您可以将应用作为应用内购买来销售吗?

ios - 快速从 UILocalNotification 迁移到 UNUserNotification

image - 有什么好的图像文本本地化算法吗?