select_lang.lib.php
来自「phpMyAdmin图形界面化操作,我已经配置好了,只要把解要压缩后的文件放到站」· PHP 代码 · 共 402 行 · 第 1/2 页
PHP
402 行
<?php/* vim: set expandtab sw=4 ts=4 sts=4: *//** * phpMyAdmin Language Loading File * * @version $Id: select_lang.lib.php 12137 2008-12-14 13:58:06Z lem9 $ */if (! defined('PHPMYADMIN')) { exit;}/** * tries to find the language to use * * @uses $GLOBALS['cfg']['lang'] * @uses $GLOBALS['cfg']['DefaultLang'] * @uses $GLOBALS['lang_failed_cfg'] * @uses $GLOBALS['lang_failed_cookie'] * @uses $GLOBALS['lang_failed_request'] * @uses $GLOBALS['convcharset'] to set it if not set * @uses $_REQUEST['lang'] * @uses $_COOKIE['pma_lang'] * @uses $_SERVER['HTTP_ACCEPT_LANGUAGE'] * @uses $_SERVER['HTTP_USER_AGENT'] * @uses PMA_langSet() * @uses PMA_langDetect() * @uses explode() * @return bool success if valid lang is found, otherwise false */function PMA_langCheck(){ // check forced language if (! empty($GLOBALS['cfg']['Lang'])) { if (PMA_langSet($GLOBALS['cfg']['Lang'])) { return true; } else { $GLOBALS['lang_failed_cfg'] = $GLOBALS['cfg']['Lang']; } } // Don't use REQUEST in following code as it might be confused by cookies with same name // check user requested language (POST) if (! empty($_POST['lang'])) { if (PMA_langSet($_POST['lang'])) { return true; } elseif (!is_string($_POST['lang'])) { /* Faked request, don't care on localisation */ $GLOBALS['lang_failed_request'] = 'Yes'; } else { $GLOBALS['lang_failed_request'] = $_POST['lang']; } } // check user requested language (GET) if (! empty($_GET['lang'])) { if (PMA_langSet($_GET['lang'])) { return true; } elseif (!is_string($_GET['lang'])) { /* Faked request, don't care on localisation */ $GLOBALS['lang_failed_request'] = 'Yes'; } else { $GLOBALS['lang_failed_request'] = $_GET['lang']; } } // check previous set language if (! empty($_COOKIE['pma_lang'])) { if (PMA_langSet($_COOKIE['pma_lang'])) { return true; } elseif (!is_string($_COOKIE['lang'])) { /* Faked request, don't care on localisation */ $GLOBALS['lang_failed_request'] = 'Yes'; } else { $GLOBALS['lang_failed_cookie'] = $_COOKIE['pma_lang']; } } // try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE variable if (PMA_getenv('HTTP_ACCEPT_LANGUAGE')) { foreach (explode(',', PMA_getenv('HTTP_ACCEPT_LANGUAGE')) as $lang) { if (PMA_langDetect($lang, 1)) { return true; } } } // try to findout user's language by checking its HTTP_USER_AGENT variable if (PMA_langDetect(PMA_getenv('HTTP_USER_AGENT'), 2)) { return true; } // Didn't catch any valid lang : we use the default settings if (PMA_langSet($GLOBALS['cfg']['DefaultLang'])) { return true; } return false;}/** * checks given lang and sets it if valid * returns true on success, otherwise flase * * @uses $GLOBALS['available_languages'] to check $lang * @uses $GLOBALS['lang'] to set it * @param string $lang language to set * @return bool success */function PMA_langSet(&$lang){ if (!is_string($lang) || empty($lang) || empty($GLOBALS['available_languages'][$lang])) { return false; } $GLOBALS['lang'] = $lang; return true;}/** * Analyzes some PHP environment variables to find the most probable language * that should be used * * @param string string to analyze * @param integer type of the PHP environment variable which value is $str * * @return bool true on success, otherwise false * * @global $available_languages * * @access private */function PMA_langDetect(&$str, $envType){ if (empty($str)) { return false; } if (empty($GLOBALS['available_languages'])) { return false; } foreach ($GLOBALS['available_languages'] as $lang => $value) { // $envType = 1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable, // 2 for the 'HTTP_USER_AGENT' one $expr = $value[0]; if (strpos($expr, '[-_]') === FALSE) { $expr = str_replace('|', '([-_][[:alpha:]]{2,3})?|', $expr); } if (($envType == 1 && preg_match('/^(' . addcslashes($expr,'/') . ')(;q=[0-9]\\.[0-9])?$/i', $str)) || ($envType == 2 && preg_match('/(\(|\[|;[[:space:]])(' . addcslashes($expr,'/') . ')(;|\]|\))/i', $str))) { if (PMA_langSet($lang)) { return true; } } } return false;} // end of the 'PMA_langDetect()' function/** * Returns list of languages supported by phpMyAdmin * * @return array */function PMA_langList(){ /** * All the supported languages have to be listed in the array below. * 1. The key must be the "official" ISO 639 language code and, if required, * the dialect code. It can also contain some information about the * charset (see the Russian case). * 2. The first of the values associated to the key is used in a regular * expression to find some keywords corresponding to the language inside two * environment variables. * These values contain: * - the "official" ISO language code and, if required, the dialect code * too ('bu' for Bulgarian, 'fr([-_][[:alpha:]]{2})?' for all French * dialects, 'zh[-_]tw' for Chinese traditional...), the dialect has to * be specified first; * - the '|' character (it means 'OR'); * - the full language name. * 3. The second value associated to the key is the name of the file to load * without the 'inc.php' extension. * 4. The third value associated to the key is the language code as defined by * the RFC1766. * 5. The fourth value is its native name in html entities. * * Beware that the sorting order (first values associated to keys by * alphabetical reverse order in the array) is important: 'zh-tw' (chinese * traditional) must be detected before 'zh' (chinese simplified) for * example. * */ return array( 'af-utf-8' => array('af|afrikaans', 'afrikaans-utf-8', 'af', ''), 'ar-utf-8' => array('ar|arabic', 'arabic-utf-8', 'ar', 'العربية'), 'az-utf-8' => array('az|azerbaijani', 'azerbaijani-utf-8', 'az', 'Azərbaycanca'), 'bn-utf-8' => array('bn|bangla', 'bangla-utf-8', 'bn', ''), 'becyr-utf-8' => array('be|belarusian', 'belarusian_cyrillic-utf-8', 'be', 'Беларуская'), 'belat-utf-8' => array('be[-_]lat|belarusian latin', 'belarusian_latin-utf-8', 'be-lat', 'Biełaruskaja'), 'bg-utf-8' => array('bg|bulgarian', 'bulgarian-utf-8', 'bg', 'Български'), 'bs-utf-8' => array('bs|bosnian', 'bosnian-utf-8', 'bs', 'Bosanski'), 'ca-utf-8' => array('ca|catalan', 'catalan-utf-8', 'ca', 'Català'),
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?