I tried to implement this solution by creating a set of localized strings with built-in HTML formatting, and the idea was to combine them to get one line that I would assign to the loadHTMLString:baseURL: UIWebView method.
However, mixing HTML with plain text in localized strings seemed like an expected nightmare in anticipation of future expectation, so instead I tried this:
I wrote a simple test HTML file with English text and copied it into my Xcode project. Then I added Spanish localization for this file. When I tested this on the iPhone Simulator, it worked fine. The line of code that I used to read the contents of the HTML file and assigned it to a UIWebView is as follows:
NSString *path = [[NSBundle mainBundle] pathForResource:@"help" ofType:@"html"]; [myUIWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];
Having multiple HTML files to support may seem like a lot of work, but it's the same thing you do when localizing nib files, and I think this approach works best when we think about decoupling this type of content from a regular localized string.
Hope this helps!
source share