Ejemplo n.º 1
0
function each_obj(&$file, $src, $obj)
{
    if (is_array($obj)) {
        foreach ($obj as $item) {
            each_obj($file, $src, $item);
        }
    } elseif (is_string($obj)) {
        if ($obj != "" && $src[md5($obj)] != "") {
            $new = str_replace("\$", "\\\$", $src[md5($obj)]);
            $obj = str_replace("\$", "\\\$", $obj);
            if (strrpos($new, "\n") == strlen($new) - 1) {
                $new = substr($new, 0, strlen($new) - 1);
            }
            $index = strpos($file, "\"" . $obj . "\"");
            if (!$index) {
                $index = strpos($file, "'" . $obj . "'");
            }
            if (!$index) {
                $index = strpos($file, $obj);
            } else {
                $index += 1;
            }
            $file = substr_replace($file, $new, $index, strlen($obj));
        }
    }
}
Ejemplo n.º 2
0
function each_obj($src_file, $obj)
{
    if (is_array($obj)) {
        foreach ($obj as $item) {
            each_obj($src_file, $item);
        }
    } elseif (is_string($obj)) {
        fwrite($src_file, md5($obj) . "\t" . $obj . "\n");
    }
}
Ejemplo n.º 3
0
function load_file($str_file, $lang, $filename)
{
    $temp_str = file_get_contents("../" . $lang . "/" . $filename);
    $temp_file = fopen("../" . $lang . "/temp_" . $filename, "w");
    $temp_str = str_replace("\n\$", "\n\$temp_", $temp_str);
    fwrite($temp_file, $temp_str);
    fclose($temp_file);
    $str = file_get_contents("../chinese_simple/" . $filename);
    while ($index = strpos($str, "\n\$", $index + 1)) {
        $stop = strpos($str, "=", $index);
        $obj = substr($str, $index + 2, $stop - $index - 2);
        each_obj($str_file, $obj, $filename, $lang);
    }
}