你可能知道iOS 8需要NSLocationWhenInUseUsageDescription键来使用用户的位置。我已经添加了这个键和一些一般信息到我的信息plist。
如何在plist文件中使用翻译字符串?
——更新——
我已经有一个Localizable字符串。我只是想知道我能不能用一些 NSLocalizedString(MYSTRING,nil)在plist字符串内。我知道我可以创建多个文件的信息。plist的本地化,但我想知道是否有一个更简单的方法。
你可能知道iOS 8需要NSLocationWhenInUseUsageDescription键来使用用户的位置。我已经添加了这个键和一些一般信息到我的信息plist。
如何在plist文件中使用翻译字符串?
——更新——
我已经有一个Localizable字符串。我只是想知道我能不能用一些 NSLocalizedString(MYSTRING,nil)在plist字符串内。我知道我可以创建多个文件的信息。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文件!
其他回答
在我的例子中,所有的设置都是正确的,但仍然是InfoPlist。字符串文件未找到。
唯一真正起作用的是,删除并添加InfoPlist。将文件再次字符串到项目。
在我的情况下,本地化没有工作,原因是名称中的'-'符号。 例如:“aero-Info.plist” 和本地化文件:“aero-InfoPlist。字符串”和“aeroInfoPlist。字符串“没有工作。
如果有些东西不工作,请确保您添加:
“本地化资源可以混合”= YES
进入info.plist。在我的例子中是InfoPlist。Strings文件被忽略了。
使用InfoPlist时。字符串文件(在XCode中,它应该放在信息旁边。Plist文件-真实的文件位置可能在项目中的任何地方
)小心使用键的短名称进行翻译。
我试图使用隐私-相机使用描述,但工作密钥是NSCameraUsageDescription
正如RGML所说,您可以创建一个InfoPlist。字符串,本地化它,然后添加你的键和值,像这样: "NSLocationWhenInUseUsageDescription" = "Help To locate me!";
它将添加到您的信息的关键。Plist指定的语言。