无法本地化info.plist字符串 [英] Can't localize info.plist strings

查看:408
本文介绍了无法本地化info.plist字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要本地化info.plist的两个键: NSLocationUsageDescription NSCameraUsageDescription 。因此,我尝试创建一个名为InfoPlist.strings的新文件,然后将其本地化,但是应用程序始终显示存储在info.plist文件中的字符串。怎么了?

I need to localize two keys of info.plist: NSLocationUsageDescription and NSCameraUsageDescription. So I tried to create a new file called InfoPlist.strings and then I localized it, but app always shows strings stored in info.plist file. What's wrong?

信息属性列表键参考


本地化值未存储在信息中。 plist文件本身。
而是将特定本地化的值存储在名称为InfoPlist.strings的
字符串文件中。您将此文件放在
相同的语言特定项目目录中,该目录用于存储
其他资源以进行相同的本地化。
InfoPlist.strings文件的内容是要本地化的单个键,
是适当转换的值。在Info.plist文件中查找键
值的例程将考虑用户的语言首选项
并返回键的本地化版本(从
合适的InfoPlist.strings文件)。一个存在。如果不存在本地化的
版本的键,则例程将返回存储在Info.plist文件中的
值。

Localized values are not stored in the Info.plist file itself. Instead, you store the values for a particular localization in a strings file with the name InfoPlist.strings. You place this file in the same language-specific project directory that you use to store other resources for the same localization. The contents of the InfoPlist.strings file are the individual keys you want localized and the appropriately translated value. The routines that look up key values in the Info.plist file take the user’s language preferences into account and return the localized version of the key (from the appropriate InfoPlist.strings file) when one exists. If a localized version of a key does not exist, the routines return the value stored in the Info.plist file.

我的InfoPlist.strings文件:

My InfoPlist.strings file:

NSCameraUsageDescription = "hello";
NSLocationUsageDescription = "hello hello";


推荐答案

请在生成的应用程序包中检查文件是否确实存储在此处,并放置在正确的位置。通常这是缺少的步骤。

Please check in the generated application package, whether the file is really stored in there and it is put to the correct location. Usually this is the missing step.

只需进入项目设置,打开构建阶段,然后查看是否可以在复制捆绑包中找到
文件资源

Just go into the project settings, open "Build Phases" and see whether the file can be found in "Copy Bundle Resources"

这篇关于无法本地化info.plist字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆