curly braces + spaces added

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2017-01-26 14:44:46 +01:00 committed by Roland Haeder
parent 15c77beee2
commit 720e7d6034
No known key found for this signature in database
GPG key ID: B72F8185C6C7BD78
7 changed files with 121 additions and 97 deletions

View file

@ -42,34 +42,45 @@ function po2php_run(&$argv, &$argc) {
foreach ($infile as $l) {
$l = str_replace('\"', DQ_ESCAPE, $l);
$len = strlen($l);
if ($l[0]=="#") $l="";
if (substr($l,0,15)=='"Plural-Forms: '){
if ($l[0]=="#") {
$l="";
}
if (substr($l,0,15) == '"Plural-Forms: '){
$match=Array();
preg_match("|nplurals=([0-9]*); *plural=(.*)[;\\\\]|", $l, $match);
$cond = str_replace('n','$n',$match[2]);
// define plural select function if not already defined
$fnname = 'string_plural_select_' . $lang;
$out .= 'if(! function_exists("'.$fnname.'")) {'."\n";
$out .= 'if (! function_exists("'.$fnname.'")) {'."\n";
$out .= 'function '. $fnname . '($n){'."\n";
$out .= ' return '.$cond.';'."\n";
$out .= '}}'."\n";
}
if ($k!="" && substr($l,0,7)=="msgstr "){
if ($ink) { $ink = False; $out .= '$a->strings["'.$k.'"] = '; }
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
if ($k!="" && substr($l,0,7) == "msgstr "){
if ($ink) {
$ink = False;
$out .= '$a->strings["'.$k.'"] = ';
}
if ($inv) {
$inv = False;
$out .= '"'.$v.'"';
}
$v = substr($l,8,$len-10);
$v = preg_replace_callback($escape_s_exp,'escape_s',$v);
$inv = True;
//$out .= $v;
}
if ($k!="" && substr($l,0,7)=="msgstr["){
if ($ink) { $ink = False; $out .= '$a->strings["'.$k.'"] = '; }
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
if ($k!="" && substr($l,0,7) == "msgstr["){
if ($ink) {
$ink = False;
$out .= '$a->strings["'.$k.'"] = ';
}
if ($inv) {
$inv = False;
$out .= '"'.$v.'"';
}
if (!$arr) {
$arr=True;
@ -85,7 +96,6 @@ function po2php_run(&$argv, &$argc) {
if (substr($l,0,6)=="msgid_") { $ink = False; $out .= '$a->strings["'.$k.'"] = '; };
if ($ink) {
$k .= trim($l,"\"\r\n");
$k = preg_replace_callback($escape_s_exp,'escape_s',$k);
@ -93,9 +103,14 @@ function po2php_run(&$argv, &$argc) {
}
if (substr($l,0,6)=="msgid "){
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
if ($k!="") $out .= $arr?");\n":";\n";
$arr=False;
if ($inv) {
$inv = False;
$out .= '"'.$v.'"';
}
if ($k != "") {
$out .= $arr?");\n":";\n";
}
$arr = False;
$k = str_replace("msgid ","",$l);
if ($k != '""' ) {
$k = trim($k,"\"\r\n");
@ -116,8 +131,13 @@ function po2php_run(&$argv, &$argc) {
}
if ($inv) { $inv = False; $out .= '"'.$v.'"'; }
if ($k!="") $out .= $arr?");\n":";\n";
if ($inv) {
$inv = False;
$out .= '"'.$v.'"';
}
if ($k!="") {
$out .= $arr?");\n":";\n";
}
$out = str_replace(DQ_ESCAPE, '\"', $out);
file_put_contents($outfile, $out);