示例#1
0
文件: po2php.php 项目: Mauru/red
            $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" && 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 . '"';
    }
    if ($k != "") {
        $out .= $arr ? ");\n" : ";\n";
    }
    file_put_contents($outfile, $out);
}
if (array_search(__FILE__, get_included_files()) === 0) {
    po2php_run($argv, $argc);
}
示例#2
0
                $out .= $arr ? ");\n" : ";\n";
            }
            $arr = False;
            $k = str_replace("msgid ", "", $l);
            if ($k != '""') {
                $k = trim($k, "\"\r\n");
            } else {
                $k = "";
            }
            $k = preg_replace_callback($escape_s_exp, 'escape_s', $k);
            $ink = True;
        }
        if ($inv && substr($l, 0, 6) != "msgstr") {
            $v .= trim($l, "\"\r\n");
            $v = preg_replace_callback($escape_s_exp, 'escape_s', $v);
            //$out .= '$a->strings['.$k.'] = ';
        }
    }
    if ($inv) {
        $inv = False;
        $out .= '"' . $v . '"';
    }
    if ($k != "") {
        $out .= $arr ? ");\n" : ";\n";
    }
    $out = str_replace(DQ_ESCAPE, '\\"', $out);
    file_put_contents($outfile, $out);
}
if (array_search(__FILE__, get_included_files()) === 0) {
    po2php_run($_SERVER["argv"], $_SERVER["argc"]);
}
示例#3
0
            $v .= trim_message($l);
            $v = preg_replace_callback($escape_s_exp, 'escape_s', $v);
            //$out .= 'App::$strings['.$k.'] = ';
        }
        if (substr($l, 0, 7) == "msgctxt") {
            $ctx = str_replace("msgctxt ", "", $l);
            $ctx = trim_message($ctx);
            $ctx = "__ctx:" . $ctx . "__ ";
            $ctx = preg_replace_callback($escape_s_exp, 'escape_s', $ctx);
        }
    }
    if ($inv) {
        $inv = False;
        $out .= '"' . $v . '"';
    }
    if ($k != "") {
        $out .= $arr ? ");\n" : ";\n";
    }
    file_put_contents($outfile, $out);
}
function trim_message($str)
{
    // Almost same as trim("\"\r\n") except that escaped quotes are preserved
    $str = trim($str, "\r\n");
    $str = ltrim($str, "\"");
    $str = preg_replace('/(?<!\\\\)"+$/', '', $str);
    return $str;
}
if (array_search(__FILE__, get_included_files()) === 0) {
    po2php_run($argc, $argv);
}