xcode 在 localizable.strings 中添加“换行符”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16337694/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Add "newline" character in localizable.strings
提问by Burhanuddin Sunelwala
How to add a newline character in localizable.strings
?
如何在中添加换行符localizable.strings
?
I tried putting \n
, but no success.
我尝试放置\n
,但没有成功。
回答by Martin R
Using \n
should just work. With this line in "Localizable.strings":
使用\n
应该只是工作。在“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
回答by Bonnie
Just adding newlines in the .strings file also works
只需在 .strings 文件中添加换行符也可以
"str" = "Hi ,
this is .
in a new line,
";
回答by Maschel
This works in an UILabel and UITextview as long as you set the appropriate line number:
只要您设置适当的行号,这在 UILabel 和 UITextview 中有效:
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.
您也可以将其设置为 0,即自动行数,您还应确保您的标签足够大以显示多行,否则它将被切断。
回答by Divyam shukla
this will not work in localizable.strings you have to create two keys and then only you can manage \n between two localizable strings during the concatination of strings.
这在 localizable.strings 中不起作用,您必须创建两个键,然后才能在字符串连接期间管理两个可本地化字符串之间的 \n。