Wednesday, October 5, 2011

msgfmt fatal error: UTF-8 with BOM

When we use msgfmt to compile a translation file, i.e., *.po file, it's easily be to occur an error:
msgfmt: found 1 fatal error *.po :1:2: syntax error
Usually we are encoding our translation files in UTF-8. However, if you try to save a text file in UTF-8 on Windows, e.g., in Notepad, the file will be prepended with a BOM. BOM (Byte Order Mark) appears in HEX format as "EF BB BF". However, msgfmt only accepts UTF-8 without BOM, and BOM will bring msgfmt a fatal error. This error is often frustrating because BOM's invisibility in normal text editor. Therefore, if you're editing a translation file, i.e., *.po file, try to use Notepad++. After editing, just go to "Encoding" and do "Convert to UTF-8 without BOM". Your translation file will be good to go now.

No comments:

Post a Comment

Post a Comment