Localizable.strings 文件.. 在 xcode4 [英] Localizable.strings files.. in xcode4

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

问题描述

在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 文件编译.如果我更改所有代码在这个文件中添加注释(like this ->//),我的项目就编译完成了.

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 文件.但他们可能解决这个我做不到的问题.因为没有关于这个问题的问题这么多.

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 文件错误验证failed:无法读取数据因为它已经损坏了.

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.

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

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