开发者

Localizable.strings woes

开发者 https://www.devze.com 2023-01-22 03:19 出处:网络
My Localizable.strings file has somehow been corrupted and I don\'t know how to restore it. If I open it as a Plain Text File it starts with weird characters that I can\'t copy here.

My Localizable.strings file has somehow been corrupted and I don't know how to restore it.

If I open it as a Plain Text File it starts with weird characters that I can't copy here.

If I leave the file be the app builds. If I make any changes either the values aren't interpreted properly or I get an error at compile time.

Localizable.strings: Conversion of string faile开发者_开发技巧d. The string is empty.
Command /Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copystrings failed with exit code 1

I suspect this is an encoding problem but I don't know how it happened (maybe SVN is to blame?) nor how to solve it. Any tips will be much more appreciated.


I have issues with the same file that sound very similar to your own. What happens for me is that Xcode doesn't know the correct file formating. I often get this when rearranging the project and I remove and re-add this file to the Xcode project. When I re-add the file, its encoding gets set to something like Western Roman which can't seem to render anything other than ASCII.

Here's what I do to fix the problem:

  • In Xcode select the Localizable.stings file in the Groups&Files panel.

  • Do a Get Info on that file.

  • On the info panel select the General tab.

  • In that tab go to the File Encoding and change its value.

The last step is where the trick lies as you now have to guess the right encoding. I find that for most European languages that "Unicode (UTF-8)" works. And for Asian languages I find that "Unicode (UTF-16/32)" are the ones to try.


I just had that error because I forgot a semicolon. Took me a while to figure it out. Seems like a really ambiguous compiler error but the fix was simple.


Make sure in File-Get Info, that UTF-16 is selected. If it's set to none or UTF-8 as encoding then you need to change it. If your characters have spaces between them then you choose to "re-interpret" the file as UTF-16. If there are weird characters in the file, then you need to remove them.


Execpt the UTF-8 problem, sometimes you still have to check the content in case if there are some syntax problems.

Use the following Regular Expression to verify your text line by line, if there's any line not matched, there must be a problem.

"(.+?)"="(.+?)";


You can use the plutil command line tool. Without options or with the -lint option, it checks the syntax of the file given as argument. It will tell you more precisely where the error is.


This happens to me when there is a missing quote or something not right with the file. MOst commonly, since my language files are done by another team member, he tends to forget a quote or something. Usually XCode shows an error on that line, sometimes it does'nt and just throws "Corrupted data" error.

Double check if all your strings are properly closed in quotes


Open the file in Xcode.

Right click it in Project Navigator.

Select Open as -> ASCII Property List

0

精彩评论

暂无评论...
验证码 换一张
取 消