I'm using a set of .po
files generated by the company translation system (with Pootle, if that's relevant). I'm having trouble converting these files to .mo
(the binary counterpart to .po
files) using the msgfmt
utility (with the -C
operator, which checks the format of the file), I get the following error:
$ msgfmt -v -C default.po
default.po:1:2: syntax error
msgfmt: found 1 fatal error
I've Googled pretty extensively for a way to get more information on what, exactly, is causing msgfmt
to throw this error.
I've also tried removing the first couple of lines of the file (which were not part of the catalog, but just comments or empty translation strings).
I'm inclined to think that it's a file encoding issue, but I've not dealt much with this type of thing, so I'm more than willing to admit that this is user error.
Does anybody know how I can more specifically diagnose the error with these files? Also, the same behavior is exhibited across all of the localized files, not just one specific file.
It sounds almost definitely like an issue with BOM, PO files should not contain them. An alternative would be to run pocompile from the Translate Toolkit, since you are already using Pootle pocompile should already be installed on your system.
My guess would also be that this is an encoding issue. Since the error already appears in the first few characters of the file the culprit is probably a byte order mark, which in utf-8 is encoded as the byte sequence 0xEF, 0xBB, 0xBF. The best way to check this would be to look at the file with a hex editor, or use an editor that can tell you whether the file contains a byte order mark.
For example in vim you can use set bomb?
and it will tell you either bomb
or nobomb
.
Edit: Here is a blog entry of someone having the exact same error message caused by an utf-8 encoded file starting with a byte order mark.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With