From 8c948f4bbe04e4221e6a845995048a565d6ce808 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 13 May 2014 02:10:06 -0700 Subject: forbid redefinition of language plural_select function --- util/po2php.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'util/po2php.php') diff --git a/util/po2php.php b/util/po2php.php index c703172af..3ac8b89dd 100644 --- a/util/po2php.php +++ b/util/po2php.php @@ -44,9 +44,10 @@ function po2php_run($argv, $argc) { $match=Array(); preg_match("|nplurals=([0-9]*); *plural=(.*)[;\\\\]|", $l, $match); $cond = str_replace('n','$n',$match[2]); + $out .= 'if(! function_exists("' . 'string_plural_select_' . $lang .'") {' . "\n"; $out .= 'function string_plural_select_' . $lang . '($n){'."\n"; $out .= ' return '.$cond.';'."\n"; - $out .= '}'."\n"; + $out .= '}}'."\n"; } -- cgit v1.2.3 From 71ded9388b71617b4eeff95d168242dac79324ac Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 13 May 2014 02:17:17 -0700 Subject: missing paren --- util/po2php.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util/po2php.php') diff --git a/util/po2php.php b/util/po2php.php index 3ac8b89dd..edb1a35a8 100644 --- a/util/po2php.php +++ b/util/po2php.php @@ -44,7 +44,7 @@ function po2php_run($argv, $argc) { $match=Array(); preg_match("|nplurals=([0-9]*); *plural=(.*)[;\\\\]|", $l, $match); $cond = str_replace('n','$n',$match[2]); - $out .= 'if(! function_exists("' . 'string_plural_select_' . $lang .'") {' . "\n"; + $out .= 'if(! function_exists("' . 'string_plural_select_' . $lang .'")) {' . "\n"; $out .= 'function string_plural_select_' . $lang . '($n){'."\n"; $out .= ' return '.$cond.';'."\n"; $out .= '}}'."\n"; -- cgit v1.2.3 From 72a633dc51b98b25c740a9cb392acfaad77148d8 Mon Sep 17 00:00:00 2001 From: Alexandre Hannud Abdo Date: Wed, 21 May 2014 04:48:22 -0300 Subject: Make translation contexts effective. --- util/po2php.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'util/po2php.php') diff --git a/util/po2php.php b/util/po2php.php index edb1a35a8..d3e6d190c 100644 --- a/util/po2php.php +++ b/util/po2php.php @@ -30,6 +30,7 @@ function po2php_run($argv, $argc) { $infile = file($pofile); $k=""; $v=""; + $ctx=""; $arr = False; $ink = False; $inv = False; @@ -92,23 +93,27 @@ function po2php_run($argv, $argc) { if ($k!="") $out .= $arr?");\n":";\n"; $arr=False; $k = str_replace("msgid ","",$l); - if ($k != '""' ) { - $k = trim($k,"\"\r\n"); - } else { - $k = ""; - } - + $k = trim($k,"\"\r\n"); + $k = $ctx.$k; + // echo $ctx ? $ctx."\nX\n":""; $k = preg_replace_callback($escape_s_exp,'escape_s',$k); + $ctx = ""; $ink = True; } - if ($inv && substr($l,0,6)!="msgstr") { + if ($inv && substr($l,0,6)!="msgstr" && substr($l,0,7)!="msgctxt") { $v .= trim($l,"\"\r\n"); $v = preg_replace_callback($escape_s_exp,'escape_s',$v); //$out .= '$a->strings['.$k.'] = '; } - - + + if (substr($l,0,7)=="msgctxt") { + $ctx = str_replace("msgctxt ","",$l); + $ctx = trim($ctx,"\"\r\n"); + $ctx = "__ctx:".$ctx."__ "; + $ctx = preg_replace_callback($escape_s_exp,'escape_s',$ctx); + } + } if ($inv) { $inv = False; $out .= '"'.$v.'"'; } -- cgit v1.2.3