Question

I am busy writing an app that needs to be localized properly but the act of manually creating the portable object templates all the time is tedious.

Can anyone tell me why this piece of code:

<?php
exec("xgettext -d templates/base -s -j -o default.pot templates/base/view.php", $output);
?>

is not doing anything but when I run that in the command line it actually populates the default.pot file with the entries it found?

Was it helpful?

Solution

I find most often problems like this are due to paths. The user php/apache runs as on your machine (normally 'nobody' or 'www-data') likely does not have the PATH environment variable set, and if it is, it probably doesn't have the path that contains xgettext. If that variable isn't set, then when executing that command bash (as that user) won't be able to find the binary.

The best way to confirm this is the problem is to put in the full path to xgettext which if you don't know you can execute which xgettext in bash to get the path and hard code it. If it works, you can either leave that path in, or if the code needs to be portable find another solution such as adding the path to the PATH environment variable for the apache user.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top