Localized.strings 的问题

发布于 2024-09-28 16:17:19 字数 429 浏览 7 评论 0原文

我的 Localized.strings 文件已损坏,我不知道如何恢复它。

如果我将其作为纯文本文件打开,它会以奇怪的字符开头,我无法在此处复制。

如果我将文件保留为应用程序构建。如果我进行任何更改,则值无法正确解释,或者在编译时出现错误。

Localizable.strings: Conversion of string failed. The string is empty.
Command /Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copystrings failed with exit code 1

我怀疑这是一个编码问题,但我不知道它是如何发生的(也许 SVN 是罪魁祸首?)也不知道如何解决它。任何提示将不胜感激。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

偏爱你一生 2024-10-05 16:17:19

我对同一个文件有问题,听起来与您自己的文件非常相似。对我来说,Xcode 不知道正确的文件格式。我在重新排列项目时经常遇到此问题,我删除此文件并将其重新添加到 Xcode 项目中。当我重新添加文件时,它的编码被设置为类似西罗马的编码,它似乎无法呈现除 ASCII 之外的任何内容。

以下是我解决该问题的方法:

  • 在 Xcode 中,选择“Groups&Files”面板中的 Localizes.stings 文件。

  • 对该文件执行“获取信息”。

  • 在信息面板上选择“常规”选项卡。

  • 在该选项卡中,转到“文件编码”并更改其值。

最后一步是技巧所在,因为您现在必须猜测正确的编码。我发现对于大多数欧洲语言来说,“Unicode (UTF-8)”是有效的。对于亚洲语言,我发现可以尝试“Unicode (UTF-16/32)”。

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.

拥醉 2024-10-05 16:17:19

我刚刚遇到这个错误是因为我忘记了分号。我花了一段时间才弄清楚。看起来像是一个非常模糊的编译器错误,但修复很简单。

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.

糖果控 2024-10-05 16:17:19

确保在“文件”-“获取信息”中选择“UTF-16”。如果它设置为 none 或 UTF-8 作为编码,那么您需要更改它。如果您的字符之间有空格,那么您选择将文件“重新解释”为 UTF-16。如果文件中有奇怪的字符,那么你需要将它们删除。

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.

隐诗 2024-10-05 16:17:19

除了UTF-8的问题,有时候还是要检查一下内容,以防有语法问题。

使用下面的正则表达式逐行验证您的文本,如果有任何行不匹配,则一定有问题。

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

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.

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

撞了怀 2024-10-05 16:17:19

您可以使用 plutil 命令行工具。如果没有选项或使用 -lint 选项,它会检查作为参数给出的文件的语法。它会更准确地告诉您错误在哪里。

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.

枫林﹌晚霞¤ 2024-10-05 16:17:19

当文件中缺少引用或有问题时,就会发生这种情况。最常见的是,由于我的语言文件是由另一位团队成员完成的,他往往会忘记引用或其他内容。通常 XCode 会在该行显示错误,有时不会,只是抛出“数据损坏”错误。

仔细检查所有字符串是否正确用引号括起来

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

也只是曾经 2024-10-05 16:17:19

在 Xcode 中打开该文件。

在项目导航器中右键单击它。

选择打开为-> ASCII 属性列表

Open the file in Xcode.

Right click it in Project Navigator.

Select Open as -> ASCII Property List

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文