Error detection in .po files

I use a set of .po files created by the company's translation system (using Pootle, if necessary). I am having problems converting these files to .mo (binary to .po files) using the msgfmt utility (with the -C operator, which checks the file format), I get the following error

 $ msgfmt -v -C default.po default.po:1:2: syntax error msgfmt: found 1 fatal error 

I searched Google pretty widely for more information on what exactly causes msgfmt to throw this error.

I also tried to delete the first couple of lines of the file (which were not part of the directory, but simply comments or empty translation lines).

I am inclined to think that this is a file encoding problem, but I have not dealt with this similar matter, therefore I am more than ready to admit that this is a user error.

Does anyone know how I can more specifically diagnose an error with these files? In addition, the same behavior appears in all localized files, and not just in one specific file.

+8
localization gettext pootle
source share
2 answers

It almost certainly sounds like a problem with the BOM, the PO files should not contain them. An alternative would be to run pocompile from the Translation Tool, since you are already using Pootle pocompile should already be installed on your system.

+7
source share

My guess would also be that this is an encoding problem. Since the error already appears in the first few characters of the file, the offender is probably a byte order byte , which in utf-8 is encoded as the byte sequence 0xEF, 0xBB, 0xBF. The best way to check this out is to look at the file with the hex editor or use an editor that can tell you if the file contains byte order.

For example, in vim can you use set bomb? and he will tell you either bomb or nobomb .

Edit: Here is a blog entry of someone having the same error message caused by a utf-8 encoded file starting with a byte order sign.

+5
source share

All Articles