你可能知道iOS 8需要NSLocationWhenInUseUsageDescription键来使用用户的位置。我已经添加了这个键和一些一般信息到我的信息plist。

如何在plist文件中使用翻译字符串?

——更新——

我已经有一个Localizable字符串。我只是想知道我能不能用一些 NSLocalizedString(MYSTRING,nil)在plist字符串内。我知道我可以创建多个文件的信息。plist的本地化,但我想知道是否有一个更简单的方法。


当前回答

对于更新的XCode 12 / 13 /…

1. 创建一个新的InfoPlist。项目中的字符串文件。

2. 选择您的文件,您应该会看到右边的边栏选项“本地化”

3.如果您想在项目的Info >>本地化中添加更多语言

它会自动创建一个“InfoPlist”的副本。字符串”为您添加的新语言。

其他回答

逐步本地化Info.plist:

Find in the Xcode the folder Resources (is placed in root) Select the folder Resources Then press the main menu File->New->File... Select in section "Resource" Strings File and press Next Then in Save As field write InfoPlist ONLY ("I" (eye) capital and "P" capital - the l (ell) after the P should not be capital) Then press Create Then select the file InfoPlist.strings that created in Resources folder and press in the right menu the button "Localize" Then you Select the Project from the Project Navigator and select the The project from project list In the info tab at the bottom you can as many as language you want (There is in section Localizations) The language you can see in Resources Folder To localize the values ("key") from info.plist file you can open with a text editor and get all the keys you want to localize You write any key as the example in any InfoPlist.strings like the above example

“NSLocationAlwaysAndWhenInUseUsageDescription”=“blabla”;

“NSLocationAlwaysUsageDescription”=“blabla2”;

这就是所有的工作,你已经本地化了你的信息。plist文件!

对于更新的XCode 12 / 13 /…

1. 创建一个新的InfoPlist。项目中的字符串文件。

2. 选择您的文件,您应该会看到右边的边栏选项“本地化”

3.如果您想在项目的Info >>本地化中添加更多语言

它会自动创建一个“InfoPlist”的副本。字符串”为您添加的新语言。

如果有些东西不工作,请确保您添加:

“本地化资源可以混合”= YES

进入info.plist。在我的例子中是InfoPlist。Strings文件被忽略了。

使用InfoPlist时。字符串文件(在XCode中,它应该放在信息旁边。Plist文件-真实的文件位置可能在项目中的任何地方

)小心使用键的短名称进行翻译。

我试图使用隐私-相机使用描述,但工作密钥是NSCameraUsageDescription

对于任何遇到信息问题的人。当尝试添加本地化时,plist不被包括,比如在Xcode 9中。

你需要制作信息。Plist localiazble通过进入它并单击文件检查器中的本地化按钮,如下所示。

info。当你添加新的本地化时,plist将被包含在文件资源中。