Question

From an Android background, I would have thought that it is possible to add a basic styling to iOS Localizable.strings by using HTML markup like over here:

http://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling

Is there any way to add some basic styling information? What would be the iOS way to display the following text in the given styling for many different languages:

Title

Information1:
blablabla

Information2:
blablabla

Do I have to add a new key for each word? That would be crazy if the structure changed based on the language... There has to be a way to do it like this for each country:

"text.screen1" = "<b>Title</b> <br><br> <i>Information1</i> ..."

Glad about any help!

Was it helpful?

Solution

The only way to display HTML is to use a UIWebView and loadHTMLString method:

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320,200)];
[webView loadHTMLString:@"test <i>italic</i>" baseURL:nil];
[self.view addSubview:webView];

You can also use \n, but you can't change font/style of the rendered text of a UITextView.

OTHER TIPS

You could store your localized strings as Markdown formatted text, parse it with something like GHMarkdownParser, and render it using an UIWebView.

Or you can just store plain HTML. I suggested Markdown because it would be easier to read.

You can also convert HTML to an NSAttributedString with a category of DTCoreText, or simply implement your own converter via NSScanner.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top