From f7461a814d7358c2773841b28890c915e60d65b0 Mon Sep 17 00:00:00 2001 From: Filip Komar Date: Wed, 15 Aug 2012 10:49:55 +0000 Subject: improved pa2lang.php: adding untranslated strings to all lang files, remove multiple spaces, backslashes --- tools/pa2lang.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/pa2lang.php b/tools/pa2lang.php index 8c28d3960..95e926641 100644 --- a/tools/pa2lang.php +++ b/tools/pa2lang.php @@ -45,7 +45,7 @@ if (is_null($php_source)) { exit(1); } -echo "Loading ", $php_source, " looking for \$$var\n"; +echo "Loading " . $php_source . " looking for \$$var\n"; include $php_source; @@ -58,10 +58,14 @@ echo sprintf("Found %d locales here: %s.\n", count($$var), implode(', ', array_keys($$var))); $files = array(); +$eng_array = $$var; +$eng_array = $eng_array['en']; +$number_of_eng_strings = count($eng_array); foreach ($$var as $k => $v) { - echo sprintf("> %s has %d strings.", $k, count($v)); + echo sprintf("> %s has %d translated strings, adding the rest %d untranslated.", $k, count($v), ($number_of_eng_strings - count($v))); + $v = array_merge($eng_array, $v); // add untranslated strings $f = array(); $f[] = sprintf('# Generated by pa2lang.php on %s', date('c')); @@ -69,7 +73,9 @@ foreach ($$var as $k => $v) { foreach ($v as $s0 => $s1) { $s0 = str_replace("\n", ' ', $s0); - + $s0 = preg_replace('/\s+/', ' ', $s0); // remove multiple spaces + $s0 = str_replace("\'", "'", $s0); // remove also backslashes + if (is_array($s1)) { echo "\nWe have an array for string $k:'$s0':\n"; foreach ($s1 as $sv) @@ -79,6 +85,8 @@ foreach ($$var as $k => $v) { exit(1); } $s1 = str_replace("\n", ' ', $s1); + $s1 = preg_replace('/\s+/', ' ', $s1); + $s1 = str_replace("\'", "'", $s1); $f[] = ''; $f[] = ';' . $s0; -- cgit v1.2.1