示例#1
0
function language_set($language = '', $force = FALSE)
{
    global $vars, $db, $lang;
    if ($force) {
        $tl = $language;
    } elseif (get('lang') != '') {
        $tl = get('lang');
    } elseif (isset($_SESSION['lang']) && $_SESSION['lang'] != '') {
        $tl = $_SESSION['lang'];
    } elseif ($language != '') {
        $tl = $language;
    } else {
        $tl = $vars['language']['default'];
    }
    if ($vars['language']['enabled'][$tl] === TRUE && file_exists(ROOT_PATH . "globals/language/" . $tl . ".php")) {
        include_once ROOT_PATH . "globals/language/" . $tl . ".php";
        if (file_exists(ROOT_PATH . "config/language/" . $tl . "_overwrite.php")) {
            include_once ROOT_PATH . "config/language/" . $tl . "_overwrite.php";
            $lang = array_multimerge($lang, $lang_overwrite);
        }
        // Set-up mbstring's internal encoding (mainly for supporting UTF-8)
        mb_internal_encoding($lang['charset']);
        // Set-up NAMES on database system
        if ($vars['db']['version'] >= 4.1) {
            $db->query("SET NAMES '" . $lang['mysql_charset'] . "'");
        }
    } else {
        if ($tl == $_SESSION['lang']) {
            unset($_SESSION['lang']);
        }
        die("WiND error: Selected language not found.");
    }
}
示例#2
0
function array_multimerge($array1, $array2)
{
    if (is_array($array2) && count($array2)) {
        foreach ($array2 as $k => $v) {
            if (is_array($v) && count($v)) {
                $array1[$k] = array_multimerge($array1[$k], $v);
            } else {
                $array1[$k] = $v;
            }
        }
    }
    return $array1;
}