예제 #1
0
파일: func.php 프로젝트: jotttt/auth
function load_translations($lang, &$l)
{
    $utimer = utime();
    $l = new stdClass();
    $fn = sprintf("%s/%s.txt", ETC_DIR, $lang);
    if (file_exists($fn)) {
        $f = new FILE();
        $f->open($fn, 'r');
        $e = explode(';', $f->read());
        // esimene lõikamine
        while (list($k, $v) = each($e)) {
            $val = $chr = '';
            $j = explode('=', trim($v));
            $k = trim($j['0']);
            // esimene element
            if (count($j) > 0) {
                for ($i = 1; $i < count($j); $i++) {
                    $val .= $chr . $j[$i];
                    $chr = '=';
                }
            } else {
                $val = $j['1'];
            }
            if (!empty($k)) {
                $l->{$k} = trim($val);
            }
        }
        $f->close();
        unset($f);
        unset($e);
        /*
         echo "<!--";
         print_r($l);
         echo "-->";
        */
        $t = stop_utimer($utimer);
        return true;
    }
    return false;
}