在头文件中使用变量和常量定义进行本地化
在这种情况下,当我有一个定义了一些参数的标头时,我该如何使用 NSLocalizedString ,比如:
#define appKey @"appKey1 is: %@"
我想我知道我的 Localized.strings 应该是这样的:
"blabla" = "appKey1 is: %@"
但是我该如何使用 NSLocalizedString 呢?我读到我需要使用 stringWithFormat,但不知道如何...
谢谢!
How do I use NSLocalizedString in this case when I have a header where I define a few parameters, say:
#define appKey @"appKey1 is: %@"
I think I know that my Localizable.strings should look like that:
"blabla" = "appKey1 is: %@"
but how do I use NSLocalizedString? I read that I need to use stringWithFormat, but not sure how...
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以将常量定义为:
然后 genstrings 工具应该以通常的方式拾取它。
在字符串文件中,它会像这样出现:
您只需翻译右侧即可。
You would define your constant as:
Then it should get picked up by the genstrings tool in the usual way.
In the strings file it would then come out like this:
And you would translate just the right hand side.
NSLocalizedStrings 中可以接受字符串文字。你需要做的是类似的事情
(确保在 Localized.strings 中以分号结束你的行,否则它最终会被损坏)。
String literals are acceptable in NSLocalizedStrings. What you need to do is something like
(Be sure to end your lines with a semi-colon in Localizable.strings, or it will end up being corrupted).
这就是你通常会这样做的方式,
因为你已经定义了它,所以你可以像这样使用它,
无论哪种情况都会像这样填充你的 myString
This is how you would do it normally,
Since you have it defined you can use it like so
Either case both would fill your myString like so