2007-07-05 05:41:18 +00:00
|
|
|
<?php
|
2009-07-11 19:45:57 +00:00
|
|
|
// not used in a single language version
|
2009-06-21 23:20:32 +00:00
|
|
|
|
2008-07-10 15:39:24 +00:00
|
|
|
$langs = array(
|
2009-04-29 11:14:11 +00:00
|
|
|
'en' => 'English', // Jakub Vrána - http://php.vrana.cz
|
2007-08-04 19:36:22 +00:00
|
|
|
'cs' => 'Čeština', // Jakub Vrána - http://php.vrana.cz
|
2010-02-17 16:47:50 +00:00
|
|
|
'sk' => 'Slovenčina', // Ivan Suchy - http://www.ivansuchy.com, Juraj Krivda - http://www.jstudio.cz
|
2008-01-08 14:01:29 +00:00
|
|
|
'nl' => 'Nederlands', // Maarten Balliauw - http://blog.maartenballiauw.be
|
2008-05-07 07:49:59 +00:00
|
|
|
'es' => 'Español', // Klemens Häckel - http://clickdimension.wordpress.com
|
2008-05-15 14:38:15 +00:00
|
|
|
'de' => 'Deutsch', // Klemens Häckel - http://clickdimension.wordpress.com
|
2008-08-22 11:34:50 +00:00
|
|
|
'fr' => 'Français', // Francis Gagné
|
2009-04-10 12:01:43 +00:00
|
|
|
'it' => 'Italiano', // Alessandro Fiorotto, Paolo Asperti
|
2008-09-01 09:35:51 +00:00
|
|
|
'et' => 'Eesti', // Priit Kallas
|
2009-07-02 15:21:16 +00:00
|
|
|
'ru' => 'Русский язык', // Maksim Izmaylov
|
2009-08-21 10:38:49 +00:00
|
|
|
'zh' => '简体中文', // Mr. Lodar
|
|
|
|
'zh-tw' => '繁體中文', // http://tzangms.com
|
2007-07-17 14:04:29 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
function lang($idf, $number = null) {
|
|
|
|
global $LANG, $translations;
|
2007-08-04 19:36:22 +00:00
|
|
|
$translation = $translations[$idf];
|
2007-07-09 15:28:37 +00:00
|
|
|
if (is_array($translation) && $translation) {
|
2009-06-21 23:20:32 +00:00
|
|
|
$pos = ($number == 1 ? 0 : ((!$number || $number >= 5) && ereg('cs|sk|ru', $LANG) ? 2 : 1)); // Slavic languages use different form for 2, 3, 4
|
2009-06-01 16:05:51 +00:00
|
|
|
$translation = $translation[$pos];
|
2007-07-05 10:46:44 +00:00
|
|
|
}
|
2007-07-25 10:19:00 +00:00
|
|
|
$args = func_get_args();
|
|
|
|
array_shift($args);
|
2008-10-27 21:14:23 +00:00
|
|
|
return vsprintf((isset($translation) ? $translation : $idf), $args);
|
2007-07-05 10:46:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function switch_lang() {
|
2008-10-03 13:15:58 +00:00
|
|
|
global $LANG, $langs;
|
|
|
|
echo "<form action=''>\n<div id='lang'>";
|
|
|
|
hidden_fields($_GET, array('lang'));
|
2009-10-02 13:21:34 +00:00
|
|
|
echo lang('Language') . ": " . html_select("lang", $langs, $LANG, "this.form.submit();");
|
2009-10-28 13:42:51 +00:00
|
|
|
echo " <input type='submit' value='" . lang('Use') . "' class='hidden'>\n";
|
2009-10-02 13:21:34 +00:00
|
|
|
echo "</div>\n</form>\n";
|
2007-07-05 10:46:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_GET["lang"])) {
|
2009-06-21 23:31:12 +00:00
|
|
|
$_COOKIE["adminer_lang"] = $_GET["lang"];
|
2009-06-21 23:20:32 +00:00
|
|
|
$_SESSION["lang"] = $_GET["lang"]; // cookies may be disabled
|
2007-07-05 05:41:18 +00:00
|
|
|
}
|
2007-07-09 15:28:37 +00:00
|
|
|
|
2008-07-10 15:39:24 +00:00
|
|
|
$LANG = "en";
|
2009-06-21 23:31:12 +00:00
|
|
|
if (isset($langs[$_COOKIE["adminer_lang"]])) {
|
2009-09-09 20:49:30 +00:00
|
|
|
cookie("adminer_lang", $_COOKIE["adminer_lang"]);
|
2009-06-21 23:31:12 +00:00
|
|
|
$LANG = $_COOKIE["adminer_lang"];
|
2007-08-04 19:36:22 +00:00
|
|
|
} elseif (isset($langs[$_SESSION["lang"]])) {
|
2007-07-27 11:43:01 +00:00
|
|
|
$LANG = $_SESSION["lang"];
|
2007-07-09 15:28:37 +00:00
|
|
|
} else {
|
2007-07-25 11:19:40 +00:00
|
|
|
$accept_language = array();
|
2009-08-05 11:30:16 +00:00
|
|
|
preg_match_all('~([-a-z]+)(;q=([0-9.]+))?~', str_replace("_", "-", strtolower($_SERVER["HTTP_ACCEPT_LANGUAGE"])), $matches, PREG_SET_ORDER);
|
2007-07-25 11:19:40 +00:00
|
|
|
foreach ($matches as $match) {
|
2009-08-05 11:30:16 +00:00
|
|
|
$accept_language[$match[1]] = (isset($match[3]) ? $match[3] : 1);
|
2007-07-25 11:19:40 +00:00
|
|
|
}
|
|
|
|
arsort($accept_language);
|
2009-01-29 13:23:59 +00:00
|
|
|
foreach ($accept_language as $key => $q) {
|
|
|
|
if (isset($langs[$key])) {
|
|
|
|
$LANG = $key;
|
2007-07-25 11:19:40 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-01-29 13:23:59 +00:00
|
|
|
$key = preg_replace('~-.*~', '', $key);
|
|
|
|
if (!isset($accept_language[$key]) && isset($langs[$key])) {
|
|
|
|
$LANG = $key;
|
2007-07-25 11:19:40 +00:00
|
|
|
break;
|
2007-07-09 15:28:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|