Merge branch 'patch-13' into 'dev'

Workaround on possible error with php2po

See merge request hubzilla/core!1247
This commit is contained in:
Mario 2018-07-30 10:01:19 +02:00
commit 4e402dca7d

View File

@ -26,32 +26,36 @@
$out = ""; $out = "";
$infile = file($pofile); $infile = file($pofile);
$k=""; $k = "";
$c = "";
$ink = False; $ink = False;
foreach ($infile as $l) { foreach ($infile as $l) {
$l = trim($l, " ");
if (!preg_match("/^msgstr\[[1-9]/",$l)) { if (!preg_match("/^msgstr\[[1-9]/",$l)) {
if ($k!="" && (substr($l,0,7)=="msgstr " || substr($l,0,8)=="msgstr[0")){ if ($k!="" && (substr($l,0,7)=="msgstr " || substr($l,0,8)=="msgstr[0")){
$ink = False; $ink = False;
$k = str_replace('\"','"',$k); $k = stripslashes($k);
$v = ""; $v = "";
if (isset(App::$strings[$k])) { if (isset(App::$strings[$k])) {
$v = App::$strings[$k]; $v = App::$strings[$k];
} else { } else {
$k = "__ctx:".$c."__ ".$k; $k = "__ctx:".$c."__ ".$k;
if (isset(App::$strings[$k])) if (isset(App::$strings[$k])) {
$v = App::$strings[$k]; $v = App::$strings[$k];
$c = "";
};
} }
if (!empty($v)) { if (!empty($v)) {
if (is_array($v)) { if (is_array($v)) {
$l = ""; $l = "";
$n = 0; $n = 0;
foreach ($v as &$value) { foreach ($v as &$value) {
$l .= "msgstr[".$n."] \"".str_replace('"','\"',$value)."\"\n"; $l .= "msgstr[".$n."] \"".addcslashes($value,"\"\n")."\"\n";
$n++; $n++;
} }
} else { } else {
$l = "msgstr \"".str_replace('"','\"',$v)."\"\n"; $l = "msgstr \"".addcslashes($v,"\"\n")."\"\n";
} }
} }
} }
@ -59,17 +63,18 @@
if (substr($l,0,6)=="msgid_" || substr($l,0,7)=="msgstr[") $ink = False; if (substr($l,0,6)=="msgid_" || substr($l,0,7)=="msgstr[") $ink = False;
if ($ink) { if ($ink) {
$k .= trim($l,"\"\r\n"); preg_match('/^"(.*)"$/',$l,$m);
$k .= $m[1];
} }
if (substr($l,0,6)=="msgid ") { if (substr($l,0,6)=="msgid ") {
preg_match('/^msgid "(.*)"/',$l,$m); preg_match('/^msgid "(.*)"$/',$l,$m);
$k = $m[1]; $k = $m[1];
$ink = True; $ink = True;
} }
if (substr($l,0,8)=="msgctxt ") { if (substr($l,0,8)=="msgctxt ") {
preg_match('/^msgctxt "(.*)"/',$l,$m); preg_match('/^msgctxt "(.*)"$/',$l,$m);
$c = $m[1]; $c = $m[1];
} }