This script executes cake i18n extract
with all the defaults args and returns the command output.
function extractPotFiles(){
$app = ROOT . DS . APP_DIR;
$cake = $app . DS . 'Console' . DS . 'cake';
$olddir = getcwd();
chdir($app);
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array('pipe', 'a')
);
$process = proc_open("$cake i18n extract --overwrite", $descriptorspec, $pipes);
$output = '';
if (is_resource($process)) {
fwrite($pipes[0], "\r\n");
fwrite($pipes[0], "\r\n");
fwrite($pipes[0], "y\r\n"); // Would you like to extract the messages from the CakePHP core
fwrite($pipes[0], "\r\n");
fwrite($pipes[0], "\r\n");
fclose($pipes[0]);
$output .= stream_get_contents($pipes[1]);
fclose($pipes[1]);
proc_close($process);
}
chdir($olddir);
return $output;
}
The return will be something like:
Welcome to CakePHP v2.6.1 Console
---------------------------------------------------------------
App : app
Path: /Applications/AMPPS/www/doare/new/doare-app/app/
---------------------------------------------------------------
Current paths: None
What is the path you would like to extract?
[Q]uit [D]one
[/Applications/AMPPS/www/project/app/] >
Current paths: /Applications/AMPPS/www/projectapp/app/
What is the path you would like to extract?
[Q]uit [D]one
[D] >
Would you like to extract the messages from the CakePHP core? (y/n)
[n] > What is the path you would like to output?
[Q]uit
[/Applications/AMPPS/www/project/app/Locale] >
Would you like to merge all domain and category strings into the default.pot file? (y/n)
[n] >
Extracting...
---------------------------------------------------------------
Paths:
/Applications/AMPPS/www/project/app/
/Applications/AMPPS/www/project/lib/Cake/
Output Directory: /Applications/AMPPS/www/project/app/Locale/
---------------------------------------------------------------
Done.