如何从显示在 iOS 下 UIWebView 控制器中的 HTML 文件中本地化一些字符串? [英] How to localize some strings from a HTML file that is displayed in a UIWebView controller under iOS?

查看:18
本文介绍了如何从显示在 iOS 下 UIWebView 控制器中的 HTML 文件中本地化一些字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法,允许我从显示在 iOS 下的 UIWebView 中的 HTML 文件中本地化一些字符串.

I am looking for a way that would allow me to localize some strings from inside a HTML file that is displayed in a UIWebView under iOS.

我想使用 NSLocalizesString() 进行本地化,所以我正在寻找一个简单的解决方案,希望我在显示之前生成本地化的 html 文件.

I want to use NSLocalizesString() for doing the localization, so I am looking for a simple solution that would like me to generate the localized html file before displaying it.

我确实可以完全控制 HTML 文件并使用某种占位符.

I do have full control over the HTML file and plant to use some kind of placeholders.

推荐答案

然后使用自定义标签,使用 NSXMLParser,以及您自定义标签中的任何内容......例如<localize>Something</localize> - 去除标签,本地化字符串,然后将此 HTML 交给您的网络视图.

Use a custom tag then, parse the HTML with NSXMLParser, and anything within your custom tag... e.g. <localize>Something</localize> - you strip the tags, localize the string, then hand this HTML over to your web view.

这篇关于如何从显示在 iOS 下 UIWebView 控制器中的 HTML 文件中本地化一些字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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