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

前端 未结 18 1185
广开言路
广开言路 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 07:06

    Your syntax seems to be fine, the only thing that I can see can "break" your file and cause this error is the quote character. Make sure to use the reqular one " and not in any other form like for example.

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

    I Had the same issue and i resolved it by commenting or removed unused strings in my Localizable.String file :)

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

    pl < Localizable.strings is better than plutil -lint Localizable.strings

    Log will show something like this

    2019-08-14 16:39:34.066 pl[21007:428513] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 427. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug. 2019-08-14 16:39:34.068 pl[21007:428513] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary on line 427. Parsing will be abandoned. Break on _CFPropertyListMissingSemicolon to debug. 2019-08-14 16:39:34.071 pl[21007:428513] *** Exception parsing ASCII property list: NSParseErrorException Error Domain=NSCocoaErrorDomain Code=3840 "Unexpected character / at line 1" UserInfo={NSDebugDescription=Unexpected character / at line 1, kCFPropertyListOldStyleParsingError=Error Domain=NSCocoaErrorDomain Code=3840 "Missing ';' on line 427" UserInfo={NSDebugDescription=Missing ';' on line 427}}

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

    For me, it was missing semi-colons. If you use a tool to generate .strings file, make sure there are no un-escaped quotes that may 'eat' the delimiting semi-colons.

    0 讨论(0)
  • 2021-01-30 07:11
    • Use plutil from the Terminal:

    you have to run it for each version of the localizable file. E.g

    1. cd into your project root
    2. cd eb.lproj - you can replace this with any localisation you are working with.
    3. plutil -lint Localizable.strings

    When you run step 3, you will either be shown an error, telling you what is wrong with your file. Or you will be told the file is OK

    Note that plutil output is bad, it seems it always says "Unexpected character at line 1" but above that output, it prints other stuff like missing semicolon on line 121, and that is the real error

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

    I know this question was asked long ago but my scenario and solution is little bit different. Today I faced same issue but when I tried to check the issue using

    plutil -lint Localizable.strings

    I got OK status which means everything is fine, then I tried to find issue using

    pl < Localizable.strings

    But again I got file text printed with no error mentioned, then I tried a trick and it worked for me.

    • Right click on the Localizable.strings file
    • Then select option Open As option
    • Then select option ASCII Property List

    That's it, XCode shows me the issue with line number and the issue was I had this DéjàVerified text as key on specified line, this helps me to identify and solve the issue, I hope it will save someone's time.

    Cheers!

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