aboutsummaryrefslogtreecommitdiffstats
path: root/tools/extract2gettext.php
diff options
context:
space:
mode:
authorFilip Komar <filip@mageia.org>2014-03-02 15:14:50 +0000
committerFilip Komar <filip@mageia.org>2014-03-02 15:14:50 +0000
commit29e810a98cc8aafdf27cc5b83530050b4d4a397b (patch)
tree1a0dcb1715fea50c8ed44e255948f4bb9b2e44ef /tools/extract2gettext.php
parentae76140d7467053ed646054daaec09ebbade7d03 (diff)
downloadwww-29e810a98cc8aafdf27cc5b83530050b4d4a397b.tar
www-29e810a98cc8aafdf27cc5b83530050b4d4a397b.tar.gz
www-29e810a98cc8aafdf27cc5b83530050b4d4a397b.tar.bz2
www-29e810a98cc8aafdf27cc5b83530050b4d4a397b.tar.xz
www-29e810a98cc8aafdf27cc5b83530050b4d4a397b.zip
added rebuilding existing po files + some error managament + verbosity improvements
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);