Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add "newline" character in localizable.strings

How to add a newline character in localizable.strings?

I tried putting \n, but no success.

like image 863
Burhanuddin Sunelwala Avatar asked May 02 '13 12:05

Burhanuddin Sunelwala


3 Answers

Using \n should just work. With this line in "Localizable.strings":

"abc" = "foo\nbar";

and this code:

NSString *s = NSLocalizedString(@"abc", NULL);
NSLog(@"%@", s);

I get the output

2013-05-02 14:14:45.931 test[4088:c07] foo
bar
like image 93
Martin R Avatar answered Nov 14 '22 16:11

Martin R


Just adding newlines in the .strings file also works

"str" = "Hi ,

this is .

in a new line,

";   
like image 20
Bonnie Avatar answered Nov 14 '22 14:11

Bonnie


This works in an UILabel and UITextview as long as you set the appropriate line number:

testLabel.numberOfLines = 2;

You could also set this to 0 which is automatic line count, also you should ensure that your label is big enough to show multiple lines, or else it will be cut off.

like image 3
Maschel Avatar answered Nov 14 '22 14:11

Maschel