如何访问标准 iOS 系统术语的可本地化字符串(例如“收藏夹”、“更多...”)?
我不知道我的方法是否从根本上是错误的,但我正在努力解决一个(看似微不足道?!)本地化问题。
我想在导航栏中显示“系统”UITabBarItem(更多、收藏夹、精选等)的标题。但我从哪里得到字符串呢? MainWindow.nib 的字符串文件不包含该字符串(我没想到它会包含),并且读取 TabBarItem 的标题返回 nil,这让我很困惑。
有人告诉我,没有办法实现它,我只需为相关术语添加我自己的本地化字符串。但我就是不(不想)相信这一点!在某些语言中这可能很容易,但是在某些语言中查找“更多”已经为我提供了多个可能的单词。我也不喜欢简单地发送这些单词进行翻译,因为这仍然取决于翻译者确切地知道苹果使用哪个术语。那么我在这里错过了一些简单的事情吗?其他人做什么?
显然,在我的测试设备上设置系统语言并简单地查看选项卡项目的标题是另一种“明显”的可能性。但我确实对这样的半生不熟的解决方法有意见。这适用于大多数语言,但当涉及俄语或日语时我真的会很开心。
我坚信必须有一种更可靠的方法来做到这一点。 SDK 中肯定有一个 .strings 文件定义了这些字符串吗?
提前致谢... 富有的
I don't know if my approach to this is fundamentally wrong, but I'm struggling to get my head around a (seemingly trivial?!) localisation issue.
I want to display the title of a 'System' UITabBarItem (More, Favorites, Featured, etc...) in a navigation bar. But where do I get the string from? The strings file of the MainWindow.nib doesn't contain the string (I didn't expect it to) and reading the title of the TabBarItem returns nil, which is what stumped me.
I've been told, there's no way to achieve it and I'll just have to add my own localised string for the terms in question. But I simply don't (want to) believe that!! That's maybe easy enough in some languages, but looking up, say, "More" in already presents me with more than one possible word in some languages. I'm not happy about simply sending these words for translation either, because it still depends on the translator knowing exactly which term Apple uses. So am I missing something simple here? What do other people do?
Obviously, setting the system language on my test device and simply looking to see what titles the Tab Items have is another 'obvious' possibility. But I really have a problem with half baked workarounds like that. That'll work for most languages, but I'm really gonna have fun when it comes to Russian or Japanese.
I'm convinced there must be a more reliable way to do this. Surely there must be a .strings file somewhere in the SDK that has these strings defined?
Thanks in advance...
Rich
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单而不幸的答案是,除了极少数标准元素(例如“后退”按钮)之外,您需要自己本地化所有字符串。是的,UIKit 有自己的 Localization.strings 文件,但显然它位于您的应用程序沙箱之外,因此您无权访问它。
几年前,我向苹果提交了一个关于为常见按钮标题、选项卡项目标签等提供操作系统级本地化的错误。该错误仍然存在,但显然他们还没有这样做(抱歉,我没有雷达#便利)。
The simple and unfortunate answer is that aside from a very few standard elements (e.g. a Back button), you need to localize all strings yourself. Yes, UIKit has its own Localization.strings file but obviously that's outside of your app sandbox so you don't have access to it.
I filed a bug with Apple years ago about providing OS-level localization for common button titles, tab item labels, etc. That bug is still open but obviously they haven't done it yet (sorry, I don't have the radar # handy).