Converts gettext translation ‘.po’ files to binary ‘.mo’ files in PHP.

Usage: is a couple of functions that take an input (.po) file and generate an output (.mo) file. Usage is easy:

    phpmo_convert( 'input.po', [ '' ] );

Just like that. You can even leave the second parameter blank, and the output file will take the same filename as the input file, with a .mo extension.

I’ve double-checked the phpmo-generated .mo binary files with those generated by Poedit, and they seem to be identical – which leads me to believe that this is production-ready.


  • If no $output_file specified, output filename is same as $input_file (but .mo)
  • Returns true/false for success/failure
  • No warranty, but if it breaks, please let me know

More info: –


Based on php-msgfmt by Matthias Bauer (Copyright © 2007), a command-line PHP tool for converting .po files to .mo. (


GPL v3

Leave a comment