diff options
author | Mario <mario@mariovavti.com> | 2018-07-28 21:23:31 +0200 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2018-07-28 21:23:31 +0200 |
commit | d85c849668c2d0b7e1eb010005e69c02b7b762c4 (patch) | |
tree | f21e5a1a285359556e606f0365893f3916d7720c /util/php2po.php | |
parent | cbd8c07265590d68bedcaa105b860cfed637e49e (diff) | |
parent | e27e0ca198d6e4890eedd7eeaa121a32ed5fba46 (diff) | |
download | volse-hubzilla-d85c849668c2d0b7e1eb010005e69c02b7b762c4.tar.gz volse-hubzilla-d85c849668c2d0b7e1eb010005e69c02b7b762c4.tar.bz2 volse-hubzilla-d85c849668c2d0b7e1eb010005e69c02b7b762c4.zip |
Merge branch 'patch-11' into 'dev'
Plural form strings export added
See merge request hubzilla/core!1245
Diffstat (limited to 'util/php2po.php')
-rw-r--r-- | util/php2po.php | 121 |
1 files changed, 62 insertions, 59 deletions
diff --git a/util/php2po.php b/util/php2po.php index c165006a1..459226f85 100644 --- a/util/php2po.php +++ b/util/php2po.php @@ -7,65 +7,68 @@ } } - if ($argc!=2) { - print "Usage: ".$argv[0]." <hstrings.php>\n\n"; - return; - } - - $phpfile = $argv[1]; - $pofile = dirname($phpfile)."/hmessages.po"; + if ($argc!=2) { + print "Usage: ".$argv[0]." <hstrings.php>\n\n"; + return; + } + + $phpfile = $argv[1]; + $pofile = dirname($phpfile)."/hmessages.po"; + + if (!file_exists($phpfile)){ + print "Unable to find '$phpfile'\n"; + return; + } + + include_once($phpfile); - if (!file_exists($phpfile)){ - print "Unable to find '$phpfile'\n"; - return; - } + print "Out to '$pofile'\n"; - include_once($phpfile); + $out = ""; + $infile = file($pofile); + $k=""; + $ink = False; + foreach ($infile as $l) { - print "Out to '$pofile'\n"; - - $out = ""; - $infile = file($pofile); - $k=""; - $ink = False; - foreach ($infile as $l) { - - if ($k!="" && substr($l,0,7)=="msgstr "){ - $ink = False; - $v = ''; - //echo "DBG: k:'$k'\n"; - if (isset(App::$strings[$k])) { - $v= App::$strings[$k]; - //echo "DBG\n"; - //var_dump($k, $v, App::$strings[$k], $v); - //echo "/DBG\n"; - - } - //echo "DBG: v:'$v'\n"; - $l = "msgstr \"".str_replace('"','\"',$v)."\"\n"; - } - - if (substr($l,0,6)=="msgid_" || substr($l,0,7)=="msgstr[" )$ink = False;; - - if ($ink) { - $k .= trim($l,"\"\r\n"); - $k = str_replace('\"','"',$k); - } - - if (substr($l,0,6)=="msgid "){ - $arr=False; - $k = str_replace("msgid ","",$l); - if ($k != '""' ) { - $k = trim($k,"\"\r\n"); - $k = str_replace('\"','"',$k); - } else { - $k = ""; - } - $ink = True; - } - - $out .= $l; - } - //echo $out; - file_put_contents($pofile, $out); -?>
\ No newline at end of file + if (!preg_match("/^msgstr\[[1-9]/",$l)) { + if ($k!="" && (substr($l,0,7)=="msgstr " || substr($l,0,8)=="msgstr[0")){ + $ink = False; + $v = ""; + if (isset(App::$strings[$k])) { + $v = App::$strings[$k]; + if (is_array($v)) { + $l = ""; + $n = 0; + foreach ($v as &$value) { + $l .= "msgstr[".$n."] \"".str_replace('"','\"',$value)."\"\n"; + $n++; + } + } else { + $l = "msgstr \"".str_replace('"','\"',$v)."\"\n"; + } + } + } + + if (substr($l,0,6)=="msgid_" || substr($l,0,7)=="msgstr[") $ink = False; + + if ($ink) { + $k .= trim($l,"\"\r\n"); + $k = str_replace('\"','"',$k); + } + + if (substr($l,0,6)=="msgid "){ + $k = str_replace("msgid ","",$l); + if ($k != '""' ) { + $k = trim($k,"\"\r\n"); + $k = str_replace('\"','"',$k); + } else { + $k = ""; + } + $ink = True; + } + + $out .= $l; + } + } + file_put_contents($pofile, $out); +?> |