xcode4中的Localizable.strings文件.. [英] Localizable.strings files.. in xcode4

查看:163
本文介绍了xcode4中的Localizable.strings文件..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在xcode4中,(我使用v4.0.1直到现在并且昨天下载了v4.0.2。)
我制作了Localizable.string文件并编译了我的项目。 (如您所知,我的源代码
使用NSLocalizedString宏函数。)

In xcode4, (I have used v4.0.1 until now and downloaded v4.0.2 yesterday.) I made Localizable.string files and compiled my project. (As you know, my source code uses NSLocalizedString macro function.)

但我的项目不能使用Localizable.string文件进行编译。如果我将此文件中的所有代码
更改为注释(如此 - > //),我的项目将完全编译。

But my project doesn't compile with Localizable.string file. If I change all code in this file to comments( like this -> // ), my project is compiled completely.

结果,问题是Localizable.string文件。我在谷歌搜索了它,
我发现UTF-8文件(Localizable.string)改为UTF-16。虽然我试过这个......这种方式也没有用。

As result, the problem is Localizable.string files. I searched about it on Google, I found that UTF-8 files (Localizable.string) is changed to UTF-16. And though I tried this... this way didn't work, too.

在这一刻,很多人都在尝试使用Localizable.string文件。但他们可能会以b $ b来解决这个我无法做到的问题。因为没有关于这个问题的问题
这么多。

On this moment, many people are trying to use Localizable.string files. But they might solve this problem that I can't do. Because there aren't the questions about this problem so many.

================== =============================================

===============================================================

在Localizable.string文件中,

In Localizable.string file,


LOCAL_APP_GRADE=基本

"LOCAL_APP_GRADE" = "Basic"

LOCAL_APP_LAST_UPDATED_DATE=
2011/04/20

"LOCAL_APP_LAST_UPDATED_DATE" = "2011/04/20"

LOCAL_MAIN_MENU_TITLE=主菜单

"LOCAL_MAIN_MENU_TITLE" = "Main Menu"

在我的源代码中,

NSLocalizedString( @"LOCAL_MAIN_MENU_TITLE", @"" );

错误信息,


复制.strings文件错误验证
失败:数据无法读取
,因为它已损坏。

Copy .strings file Error Validation failed: The data couldn't be read because it has been corrupted.


推荐答案

我在这里假设Xcode 4。仔细检查文件检查器中每个Localization.string文件的编码显示内容。当我遇到该错误时,由于其中一个文件被读作Mac Roman而不是UTF-16。一旦我改变了编码,警告便消失了。一开始让我疯狂的是,警告只发生在Xcode 4中.Xcode 3没有给出它。

I'm assuming Xcode 4 here. Double check what it shows for the encoding on each of the Localization.string files in the file inspector. When I was having that error it was due to one of the files being read as Mac Roman instead of UTF-16. Once I changed the encoding the warning went away. What was driving me nuts at first was that the warning was only happening in Xcode 4. Xcode 3 did not give it.

你的格式也存在问题.string文件。所有行都应以分号结尾。

You also have an issue with the formatting of your .string file. All of the lines should end in a semicolon.

"LOCAL_APP_GRADE" = "Basic";
"LOCAL_APP_LAST_UPDATED_DATE" = "2011/04/20";
"LOCAL_MAIN_MENU_TITLE" = "Main Menu"; 

我不认为这是警告的原因。至少我从没见过它的警告。当LOCAL_MAIN_MENU_TITLE显示在应用程序而不是主菜单中时,它通常仅在运行时显示。如果构建过程确实检查了分号,那将是很好的。在编辑文件时很容易错过添加一个。

I don't think this is the cause of the warning though. At least I've never seen a warning for it. It usually only manifests itself at runtime when LOCAL_MAIN_MENU_TITLE shows up in app instead of Main Menu. It would be nice if the build process did check for semicolons though. It's easy to miss adding one when editing the files.

这篇关于xcode4中的Localizable.strings文件..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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