您可以通过编程方式访问 Cocoa Touch 中的标准本地化字符串吗?
一些 iOS 控件具有 Apple 内置的本地化字符串。 “完成”、“编辑”、“返回”栏按钮项目是一些示例。有没有办法访问这些字符串?
我正在制作一个带有标准“删除”或“取消”选项的 UIActionSheet,就像您在“联系人”应用程序中删除联系人一样。
有没有办法在代码中引用这些字符串?如果没有,是否有地方至少可以获取这些字符串(例如从 Apple 应用程序的资源中提取它们)?它将节省额外的本地化工作,并确保与平台的一致性。
Some iOS controls have localised strings built in by Apple. The "Done", "Edit", "Back" bar button items are some examples. Is there a way to access these strings?
I am making a UIActionSheet with standard "Delete" or "Cancel" options, just like when you delete a contact in the Contacts app.
Is there a way to reference these strings in code? If not, is there somewhere I can at least get these strings (like extracting them from the resources of an Apple app)? It would save extra localisation work and would ensure consistency with the platform.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果 iOS 就像 Mac OS 一样,每个应用程序都带有自己的 Localized.strings 文件。
在每个字符串文件中,您都有所有这些小字符串,例如“完成”、“编辑”、“取消”等。
这些是我从 Finder.app 的英文 Localized.string 文件中复制的一些字符串:
您明白了。每个小字符串都在每个应用程序中进行了本地化。
这个来自 iTunes.app。
看起来更有条理一些。不过,复制他们的文件可能是不允许的;-)
Apple Developer 的 Quinn (eskimo1) 的 apples devforum 中的答案关系。
虽然2岁了。但较新的线程具有相同的结果。没有办法得到这些字符串。
If iOS is like Mac OS each app carries their own Localizable.strings file.
And in each strings file you have all those little strings like Done, Edit, Cancel and so on.
These are some strings I copied from the English Localizable.string file from Finder.app:
You get the idea. Each little string is localized in each app.
This one is from iTunes.app.
Looks a little bit more structured. Copying their files is probably not allowed though ;-)
An answer in apples devforum by Quinn (eskimo1) from Apple Developer Relations.
2 years old though. But newer threads have the same outcome. No way to get those strings.
可以使用以下代码片段从 UIKit 包中访问本地化字符串:
完全归功于 0xced (XCDFormInputAccessoryView 中的用法)
It's possible to access the localised strings from the UIKit bundle with this snippet:
Full credit goes to 0xced (Usage in XCDFormInputAccessoryView)