Localizable.strings - The data couldn’t be read because it isn’t in the correct format

前端 未结 18 1186
广开言路
广开言路 2021-01-30 06:20

If I copy something from textedit or web and paste it to localizable file it shows this compilation error. If I type those in localizable file it does not show any error. I am a

相关标签:
18条回答
  • 2021-01-30 06:58

    In my case, I was missing "=" between a string pair. Even plutil did not help me to spot the error line. I manually checked each string pair. :/

    0 讨论(0)
  • 2021-01-30 06:58

    I ran into this issue, all my formatting was correct. Checking for illegal characters using plutil -lint Localizable.strings and using ruby libraries like "utf8_utils" also didn't work at finding the illegal characters. BUT when I pasted the Localizable.strings contents into the Terminal app while running irb, it did show me the weird characters.

    "PercentComplete" = "%d procent gennemført";
    

    Pasted into irb:

    "PercentComplete"\U+FFC2\U+FFA0= "%d procent gennemf\U+FFC3\U+FFB8rt";
    

    Then all I had to do was a regex replace to fix those weird white space characters: \U+FFC2\U+FFA0

    0 讨论(0)
  • 2021-01-30 06:59

    Also make sure the strings file name is always Localizable.strings

    0 讨论(0)
  • 2021-01-30 06:59

    It seems like SVN is having some issue with this file. As it consider it to be a binary file. It is inserting a lot of non printable characters between each characters. I still couldn't find a proper solution. Just changing the Localizable.string files from production PC for avoiding any issue with it.

    Update: Updating the SVN client (smartSVN) to the latest version solved the issue. It seems one of my colleague was using a older version. When he commited the change to localizable file it caused the error.

    0 讨论(0)
  • 2021-01-30 07:00

    I once had a similar error and it turned out that there was an URL in the middle of the file, like this:

    // Some Comment 1
    "Some key 1" = "Some value 1";
    http://...whatever...
    // Some Comment 2
    "Some key 2" = "Some value 2";
    

    When calling plutil -lint on that file the output was:

    Unexpected character / at line 1
    

    Well, the first character indeed was / as the file started with a comment but the problem resolved after removing the URL; or turning it into a comment which it actually should have been. Note that the URL was nowhere near the beginning of the strings file, it was about in the middle of a 6000 lines string file. I was only able to find it by browsing through commit history and always look at the changes.

    0 讨论(0)
  • 2021-01-30 07:03

    if missing ";" at end of the all lines in Localizable.string file, this error can occur.

    eg :- "header_text" = "Current Language"; "change_language" = "Change Language";

    "header_text" = "වත්මන් භාෂාව"; "change_language" = "භාෂාව වෙනස් කරන්න";

    0 讨论(0)
提交回复
热议问题