Skip to content
Converts gettext translation '.po' files to binary '.mo' files in PHP. Working but unsupported.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
php-mo.php 0.1

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


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


GPL v3

You can’t perform that action at this time.