My friends and family are under attack in Ukraine. Donate to protect them directly or help international organizations.

XLIFF Parsing Error

April 23rd, 2010

Most of the Web applications that I build are multilingual. Since I use the symfony framework often, I rely on the XLIFF standard.

The error

I used to ask my clients to send me a Word document with the translated text. This is the format that they are most comfortable with. An error occurred recently when I copied the text directly from the document to an XLIFF file. For some reason, I could only see the original, English values.

The cause and solution

I would have probably not found the error had I not validated the XML translation file. It gave me a parsing error right in the middle of various strings. They looked fine until I turned on the special characters. Apparently, some special, invisible characters generated a parsing error and broke my application. I sanitized my strings and voilà!

Good practices

Since that incident, I always turn on the special characters in my text editor so that I may pick up any glitches earlier. Also, I no longer ask clients to supply a Word document, but rather a plain text document created with Notepad. To some more technical clients, I even supply the XML with empty tags that they may fill in. That makes less work for me, gives satisfaction to the clients, because they feel empowered, and prevents any parsing errors.

Previous: How to extract icons on OSX Next: Doctrine Translation in leftJoin()