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

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

——更新——

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


当前回答

在我的例子中,所有的设置都是正确的,但仍然是InfoPlist。字符串文件未找到。

唯一真正起作用的是,删除并添加InfoPlist。将文件再次字符串到项目。

其他回答

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

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

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

在我的情况下,本地化没有工作,原因是名称中的'-'符号。 例如:“aero-Info.plist” 和本地化文件:“aero-InfoPlist。字符串”和“aeroInfoPlist。字符串“没有工作。

你应该使用InfoPlist。字符串文件(保留I和P大写)来本地化Info.plist的值。进入“File->New->File”,在iOS的“Resource”页签下选择“Strings File”,命名为InfoPlist,进行创建。打开并插入信息。你想本地化的Plist值:

NSLocationWhenInUseUsageDescription = "Description of this";

现在可以本地化InfoPlist了。带有翻译的字符串文件。

选择本地化选项,或根据需要启用本地化,

您应该能够在左侧编辑器中看到该文件。

注意:在模拟器上测试本地化时。你需要改变模拟器本身的语言而不仅仅是Xcode目标中的语言。(约翰·韦伯致谢)

这是信息的官方文档。Plist键本地化。

感谢马可,感谢你在这个回答中包含的照片!

逐步本地化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文件!

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

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

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