iPhone:界面生成器中的 NSLocalizedString?
有什么方法可以在界面生成器中插入 NSLocalizedString 吗? 例如,将标签文本设置为本地化字符串而不是静态字符串?
我真的很讨厌为每个需要本地化字符串的单个项目创建一个属性。
Is there any way to insert an NSLocalizedString in interface builder.
For example set a label text to a localized string instead of a static string?
I really hate to create a property for every single item that requires a localized string.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
这篇文章可能会给您一些提示:
http://blog .wilshipley.com/2009/10/pimp-my-code-part-17-lost-in.html
This post might have some tips for you:
http://blog.wilshipley.com/2009/10/pimp-my-code-part-17-lost-in.html
即使这篇文章很旧,对于那些对自动本地化 IB 文件感兴趣的人,请查看以下内容:https://github.com/angelolloqui/AGi18n
免责声明:我是该库的开发者
Even if this post is old, for those interested in automatically localizing your IB files, check this out: https://github.com/angelolloqui/AGi18n
DISCLAIMER: I am the developer of the library
您可以高级使用用户定义的运行时属性:
http:// /cupobjc.blogspot.com.es/2014/04/interfaz-builder-localization.html
首先为 UILabel 定义一个新类别:
然后在界面生成器中,用户定义的运行时属性:
textLocalized String 将您的字符串本地化
< img src="https://i.sstatic.net/oaKLE.png" alt="在此处输入图像描述">
You can take advanced of the User Defined Runtime Attributes:
http://cupobjc.blogspot.com.es/2014/04/interfaz-builder-localization.html
First define a new category for UILabel:
Then in the interface builder, User Defined Runtime Attributes :
textLocalized String your string to localized
为了避免创建一堆类别,请仅创建一个对 NSObject 进行分类的类别,然后按照建议检查 isKindOfClass。请参阅下面的代码:
To avoid creating a bunch of categories, create just one that categorize the NSObject and then check for the isKindOfClass as suggested. See the code below:
NSLocalizedString 不是本地化 Interface Builder 文件的推荐方法。查看
ibtool
:http:// /www.bdunagan.com/2009/03/15/ibtool-localization-made-easy/
NSLocalizedString is not the recommended way to localize Interface Builder files. Check out
ibtool
:http://www.bdunagan.com/2009/03/15/ibtool-localization-made-easy/
我已经做了@OAK 提到的同样的事情。这是完整的代码。
界面生成器本地化指南
I have done same thing as @OAK mentioned. Here is full code.
Interface Builder Localization HowTo