Pete171 Pete171 - 1 year ago 165
Linux Question

.PO to .MO - Programmatic Conversion (PHP)

I am planning to allow users to generate .POT files/.PO files through a PHP user interface as part of CMS solution. Once these files have been generated (the easy bit) I would like to allow my system to automatically convert these files into .MO files in response to a user (POST) request.

I have seen the following question on SO:

.po to .mo convertor in php?

I understand that I could run

by using PHP's
function, but that seems to be a Linux only solution, if I am correct? How would I do this on other operating systems?
Some example code of how this may be done in practice would also be really useful, if anybody would be kind enough to demonstrate. This is quite different from the work I usually do!

This is only a concept at the moment but I hope I'm going along the right lines. If there are any additional thoughts/suggestions you have regarding this method, I'd be glad to hear them. Background information follows.

Additional Background Information - Not required:

I am retrieving the original English text by parsing simple template files that consist of nothing more than basic HTML and calls to
<?php _('the gettext method'); ?>
. These templates are parsed when edited/saved and the language entries are retrieved. The .POT file will then be generated. The user would now have to edit translations manually (through a simple interface, not directly) to update/prepare all the .PO files. Once this is done, I would need to be able to convert them to .MO files, as is the title of my question.

Answer Source

There are also PHP-only reimplementations of msgfmt if that is what you are looking for:

As alternative there would also be the Translate/Pootle webapp, with its php2po script, but there must also be some .mo conversion functions in it... (Ooops no, it's in Python.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download