如何在不为每种语言创建 xib 的情况下本地化 xib 视图中的文本?
我想本地化 xib 视图中的文本。目前我对每种语言都有几个 xib。
是否可以本地化 xib 文件中的文本,而无需为每种语言创建单独的 xib?
I want to localize text inside xib view. Currently I have several xibs for each language.
Is it possible to localize the text inside xib file without creating separate xibs for each language?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
听起来您想了解 .string 文件。
您可以查看以下相关问题以获取更多信息:
将 .string 文件作为 NSDictionary 打开
Sounds like you want to learn about .string files.
Here is a related question you can look at for more info:
Open .string files as an NSDictionary
来自Android背景,我问了同样的问题。甚至 Apple 建议创建单独的 xib每种语言的文件。幸运的是,可以在构建脚本中使用 ibtool 来自动化此过程。 这篇文章对此进行了很好的描述。
Coming from Android background, I was asking the same question. Even Apple recommends creating separate xib files for each language. Fortunately, this process can be automated using the
ibtool
in a build script. It's described nicely in this article.http://www.raywenderlich.com/2876/how -本地化 iPhone 应用程序教程
http://www.raywenderlich.com/2876/how-to-localize-an-iphone-app-tutorial
这个问题快把我逼疯了。
我在尝试让 xib 本地化变得更容易时遇到了这篇文章和其他几篇文章。我发布了在这个问题上包含标签/按钮的 IBOutles 的方法,对我来说效果很好,将所有更改限制在 Localization.strings 文件中。
https://stackoverflow.com/a/15485572/1449834
This problem was driving me nuts.
I came across this post and several others while trying to make xib localization easier for myself. I posted my method of including IBOutles for labels/buttons on this question, worked great for me, keeps all changes limited to the Localization.strings files.
https://stackoverflow.com/a/15485572/1449834
我认为直接本地化 xibs 不是一个好的选择。我正在使用 https://github.com/steipete/Aspects 来挂钩 UILabel 的 awakeFromNib 方法和在那里本地化文本。示例:
如果您有 UIButton 和其他 UIView 需要处理,您可以直接挂接 UIView 的 awakeFromNib 并本地化每种视图。
I think localize xibs directly is not an good option. I'm using https://github.com/steipete/Aspects to hook the awakeFromNib method of UILabel and localize text there. Example:
If you have UIButton and other UIView to handle, you could just hook awakeFromNib of UIView and localize each kind of view.