Converts gettext translation ‘.po’ files to binary ‘.mo’ files in PHP.
php.mo is a couple of functions that take an input (.po) file and generate an output (.mo) file. Usage is easy:
<?php require('php-mo.php'); phpmo_convert( 'input.po', [ 'output.mo' ] ); ?>
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. (http://wordpress-soc-2007.googlecode.com/svn/trunk/moeffju/php-msgfmt/msgfmt.php)
GPL v3 http://www.opensource.org/licenses/gpl-3.0.html