update translation utils:

po2php: add "if function_exists" around plural select function
run_xgettext: add option to extract strings from addon folder
This commit is contained in:
Fabrixxm 2013-02-27 08:25:03 -05:00
parent cd8346694b
commit 9d99a531b9
2 changed files with 59 additions and 23 deletions

View file

@ -46,9 +46,12 @@ function po2php_run(&$argv, &$argc) {
$match=Array();
preg_match("|nplurals=([0-9]*); *plural=(.*)[;\\\\]|", $l, $match);
$cond = str_replace('n','$n',$match[2]);
$out .= 'function string_plural_select_' . $lang . '($n){'."\n";
// define plural select function if not already defined
$fnname = 'string_plural_select_' . $lang;
$out .= 'if(! function_exists("'.$fnname.'")) {'."\n";
$out .= 'function '. $fnname . '($n){'."\n";
$out .= ' return '.$cond.';'."\n";
$out .= '}'."\n";
$out .= '}}'."\n";
}