从故事板本地化归因于UITextView [英] Localizing attributed UITextView from storyboard

查看:88
本文介绍了从故事板本地化归因于UITextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用故事板并且有一个视图,我已经将一些UITextViews子类化。

I am using the storyboard and have a view where I have subclassed some UITextViews.

我的问题是我使用 ibtool - generate-strings-file 从故事板中提取字符串以进行本地化,然后在另一个故事板文件上使用 ibtool -write 来应用翻译后的字符串。

My problem is that I am using ibtool --generate-strings-file to extract strings from the storyboard for localization and afterwards use ibtool -write on another storyboard file to apply the translated strings.

当我使用 ibtool 时, ibtool会忽略任何已归因于文本的UITextViews - 生成字符串文件命令并从结果字符串文件中省略。

When I use ibtool any UITextViews that have attributed text is ignored by the ibtool --generate-strings-file command and omitted from the resulting strings file.

是否可以从故事板中提取属性文本以进行本地化?

Is it possible to extract attributed text from a storyboard for localization?

推荐答案

我最后得出的结论是,使用 ibtool 无法完成在目前的版本。

I ended up concluding that it couldn't be done using ibtool in the present version.

相反,我让Textview成为纯文本视图,并使用我的子类解析其text属性,以便我可以创建一个 NSMutableAttributedString 并设置所需的属性。

Instead I let the Textview be a plain text view and, using my subclass, parsed its text property so I could make a NSMutableAttributedString and set the needed properties.

这使我能够使用 ibtool 来提取字符串并且仍然有一个属性textview。

That enabled me to use ibtool to extract the strings and still have an attributed textview.

这篇关于从故事板本地化归因于UITextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆