aboutsummaryrefslogtreecommitdiffstats
path: root/tools/extract2gettext.php
diff options
context:
space:
mode:
Diffstat (limited to 'tools/extract2gettext.php')
-rw-r--r--tools/extract2gettext.php16
1 files changed, 12 insertions, 4 deletions
diff --git a/tools/extract2gettext.php b/tools/extract2gettext.php
index 559285573..0b1687540 100644
--- a/tools/extract2gettext.php
+++ b/tools/extract2gettext.php
@@ -24,6 +24,7 @@ define('APP_ROOT', realpath(__DIR__ . '/..'));
$php_source = isset($argv[1]) ? $argv[1] : null;
$domain = isset($argv[2]) ? $argv[2] : null;
+$quiet = isset($argv[3]) ? $argv[3] : false;
if (is_null($php_source) || is_null($domain)) {
echo <<<U
@@ -42,16 +43,21 @@ U;
date_default_timezone_set(@date_default_timezone_get());
-echo "ohay!\n";
+if(!$quiet) { echo "ohay!\n";}
$cmd = sprintf('grep -HrnEi "_(g|r)\((.*)" %s', $php_source);
-//echo $cmd, "\n";
+if(!$quiet) { echo $cmd, "\n"; }
exec($cmd, $out);
$strings = array();
$f = array();
$error = 0;
+if(count($out) == 0) {
+ echo "No strings to save from $php_source.\n";
+ $error = 1;
+}
+
foreach ($out as $str) {
$arr = explode(':', $str);
$file = array_shift($arr);
@@ -119,8 +125,10 @@ foreach ($strings as $domain => $strs) {
mkdir($dir, 0755, true);
}
echo sprintf("saved %d strings in %s\n", count($strs), $dest);
- if (FALSE === file_put_contents($dest, $f))
+ if (FALSE === file_put_contents($dest, $f)) {
echo "Failed to write.\n";
+ $error = 3;
+ }
}
-echo "Done. thxbye.\n";
+if(!$quiet) { echo "Done. thxbye.\n"; }
exit($error);