17 throw new Exception(
"Exec : $cmd - " . print_r(
$out,
true));
24 return sprintf(
"%s extract tranlation from layout files\n
25 %s -o <output pot file> <input file> [<input file>...]\n
26 If option has '-f-', '-', files from stdin are used\n", $argv[0], $argv[0]);
29 abstract public function extract();
33 return implode(
" ", $this->options);
39 $this->options = array_slice($argv, 1);
40 $options = getopt(
"o:f:x:", array(
45 if (isset($options[
"o"]) || isset($options[
"output"])) {
46 if (!empty($options[
"o"])) {
47 $this->outputFile = $options[
"o"];
49 $this->outputFile = $options[
"output"];
53 if ((isset($options[
"f"]) && $options[
"f"] ==
"-") || (isset($options[
"files-from"]) && $options[
"files-from"] ==
"-")) {
54 $sFiles = file_get_contents(
'php://stdin');
55 $this->inputFiles = preg_split(
'/[\s,]+/', $sFiles);
56 foreach ($this->inputFiles as $k =>
$file) {
57 if (trim(
$file) ==
"") {
58 unset($this->inputFiles[$k]);
62 $this->options = explode(
' ', preg_replace(
'/\s+(-f\s*-)/',
'', implode(
' ', $this->options)));
63 $this->options = explode(
' ', preg_replace(
'/\s+(--files-from\s*=\s*-)/',
'', implode(
' ', $this->options)));
65 $lastIndex = count($argv) - 1;
66 $lastOptionIndex = $lastIndex;
67 while ($lastIndex > 0) {
68 if (substr($argv[$lastIndex], 0, 1) ==
'-') {
69 $lastOptionIndex = $lastIndex;
74 $lastOpt = $argv[$lastOptionIndex];
75 if ($lastOpt ==
"-o" || $lastOpt ==
"-x" || $lastOpt ==
"-output" || $lastOpt ==
"-exclude-file") {
76 $this->inputFiles = array_slice($argv, $lastOptionIndex + 2);
77 $this->options = array_slice($argv, 1, $lastOptionIndex + 1);
79 $this->inputFiles = array_slice($argv, $lastOptionIndex + 1);
80 $this->options = array_slice($argv, 1, $lastOptionIndex);
foreach($argv as $arg) $cmd