From 35fb04b2f7b6c96abf25ddc8a5ee1851c185b8c5 Mon Sep 17 00:00:00 2001 From: filip Date: Sat, 21 Feb 2015 22:09:58 +0100 Subject: fix for a bug where the script couldn't handle double quotes for i18n strings --- tools/extract2gettext.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'tools') diff --git a/tools/extract2gettext.php b/tools/extract2gettext.php index 73e873333..1fef6732a 100644 --- a/tools/extract2gettext.php +++ b/tools/extract2gettext.php @@ -45,7 +45,7 @@ date_default_timezone_set(@date_default_timezone_get()); if(!$quiet) { echo "ohay!\n";} -$cmd = sprintf('grep -HrnEi "_(g|r|t)\([^$](.*)" %s', $php_source); +$cmd = sprintf('grep -HrnE "_(g|r|t)\([^$](.*)" %s', $php_source); if(!$quiet) { echo $cmd, "\n"; } exec($cmd, $out); @@ -67,10 +67,13 @@ foreach ($out as $str) { $arr = implode(':', $arr); $arr = str_replace('\\\'', '_apostrophe_', $arr); - if (preg_match_all('/\_(g|r|t)\(\'(.+)\'/imU', $arr, $reg)) { // i=PCRE_CASELESS, m=PCRE_MULTILINE, U=PCRE_UNGREEDY - foreach ($reg[2] as $found) { - $found = str_replace('_apostrophe_', '\'', $found); - $strings[$domain][$found][] = '/web/' . $file . ' +' . $line; + if (preg_match_all('/\_(g|r|t)\(((\'(.+)\')|("(.+)"))/mU', $arr, $reg)) { // m=PCRE_MULTILINE, U=PCRE_UNGREEDY + $results = array_merge($reg[4], $reg[6]); + foreach ($results as $found) { + if(!empty($found)) { + $found = str_replace('_apostrophe_', '\'', $found); + $strings[$domain][$found][] = '/web/' . $file . ' +' . $line; + } } } else { $parse_error = "\n\n!!!! Could not find string in $file, line $line: $str\n"; -- cgit v1.2.1