Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
252 views
in Technique[技术] by (71.8m points)

iphone - Localizable.strings files.. in xcode4

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.)

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.

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.

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.

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

In Localizable.string file,

"LOCAL_APP_GRADE" = "Basic"

"LOCAL_APP_LAST_UPDATED_DATE" = "2011/04/20"

"LOCAL_MAIN_MENU_TITLE" = "Main Menu"

In my source code,

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

Error message,

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

question from:https://stackoverflow.com/questions/5683803/localizable-strings-files-in-xcode4

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

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"; 

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...