如何本地化iOS info.plist文件中的字符串? [英] How to localise a string inside the iOS info.plist file?
问题描述
您可能知道 iOS 8 需要 NSLocationWhenInUseUsageDescription 键才能使用用户的位置。我已将此密钥和一些常规信息添加到我的信息plist中。
As you might know the iOS 8 requires NSLocationWhenInUseUsageDescription key for using user's location. I have added this key and some general information into my info plist.
如何我可以在plist文件中使用翻译字符串吗?
How can I use translation string inside the plist file ?
- 更新 -
我已经有了Localizable串。我只是想知道我可以在plist字符串中使用类似
NSLocalizedString(MYSTRING,nil)的东西。我知道我可以创建多个info.plist文件进行本地化,但我想知道可能有更简单的方法。
I already have a Localizable string. I'm just wondering that can I use something like NSLocalizedString(MYSTRING,nil) inside the plist string. I know that I can create multiple file of info.plist for localisation but I was wondering there might be an easier way.
推荐答案
您应该使用 InfoPlist.strings
文件来本地化 Info.plist
的值。为此,请转到文件 - >新建>文件
,在<$ c $下选择字符串文件
c> iOS
的资源标签,将其命名为 InfoPlist
,然后创建。打开并插入您想要本地化的 Info.plist
值:
You should use InfoPlist.strings
file to localize values of Info.plist
. To do this, go to File->New->File
, choose Strings File
under Resource
tab of iOS
, name it InfoPlist
, and create. Open and insert the Info.plist
values you want to localize like:
"NSLocationWhenInUseUsageDescription" = "Description of this";
现在你可以本地化 InfoPlist.strings
文件翻译。祝你好运!
Now you can localize InfoPlist.strings
file with translations. Good Luck!
编辑:
选择本地化选项,或根据需要启用本地化,
select the localization options, or enable localization if needed,
您也应该能够在左侧编辑器中看到该文件。
you should be able to see the file also on the left side editor.
编辑:
此处是官方 Info.plist
密钥本地化的文档。
Here is the official documentation for Info.plist
keys localization.
这篇关于如何本地化iOS info.plist文件中的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!