X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FConsole%2FPoToPhp.php;h=d539eae5b6a3f221317fbe5cb58ccff1f5664889;hb=efe358c617d18740b63cd0dcb1ee23591fcb0e2d;hp=0a7224503ac3956bdf43f40d6b26f9f143035cab;hpb=641bd5eaa6f4ff2f7c975d87d60dd7bba8829eba;p=friendica.git diff --git a/src/Core/Console/PoToPhp.php b/src/Core/Console/PoToPhp.php index 0a7224503a..d539eae5b6 100644 --- a/src/Core/Console/PoToPhp.php +++ b/src/Core/Console/PoToPhp.php @@ -5,7 +5,7 @@ namespace Friendica\Core\Console; /** * Read a messages.po file and create strings.php in the same directory * - * @author Hypolite Petovan + * @author Hypolite Petovan */ class PoToPhp extends \Asika\SimpleConsole\Console { @@ -47,8 +47,6 @@ HELP; throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments'); } - $a = get_app(); - $pofile = realpath($this->getArgument(0)); if (!file_exists($pofile)) { @@ -61,7 +59,7 @@ HELP; $outfile = dirname($pofile) . DIRECTORY_SEPARATOR . 'strings.php'; - if (strstr($outfile, 'util')) { + if (basename(dirname($pofile)) == 'C') { $lang = 'en'; } else { $lang = str_replace('-', '_', basename(dirname($pofile))); @@ -94,26 +92,27 @@ HELP; $fnname = 'string_plural_select_' . $lang; $out .= 'if(! function_exists("' . $fnname . '")) {' . "\n"; $out .= 'function ' . $fnname . '($n){' . "\n"; + $out .= ' $n = intval($n);' . "\n"; $out .= ' return ' . $cond . ';' . "\n"; $out .= '}}' . "\n"; } - if ($k != "" && substr($l, 0, 7) == 'msgstr ') { + 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 - 11); + $v = substr($l, 8, $len - 10); $v = preg_replace_callback($escape_s_exp, [$this, 'escapeDollar'], $v); $inv = true; } + if ($k != "" && substr($l, 0, 7) == 'msgstr[') { if ($ink) { $ink = false; @@ -125,9 +124,10 @@ HELP; } if (!$arr) { - $arr = True; + $arr = true; $out .= "[\n"; } + $match = []; preg_match("|\[([0-9]*)\] (.*)|", $l, $match); $out .= "\t" @@ -152,9 +152,11 @@ HELP; $inv = false; $out .= '"' . $v . '"'; } + if ($k != "") { $out .= ($arr) ? "];\n" : ";\n"; } + $arr = false; $k = str_replace("msgid ", "", $l); if ($k != '""') { @@ -174,7 +176,6 @@ HELP; } if ($inv) { - $inv = false; $out .= '"' . $v . '"'; }