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(
|
2011-02-08 18:58:33 +00:00
|
|
|
'en' => 'English', // Jakub Vrána - http://www.vrana.cz
|
|
|
|
'cs' => 'Čeština', // Jakub Vrána - http://www.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
|
2010-08-06 09:02:19 +00:00
|
|
|
'fr' => 'Français', // Francis Gagné, Aurélien Royer
|
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
|
2010-10-07 14:03:22 +00:00
|
|
|
'hu' => 'Magyar', // Borsos Szilárd (Borsosfi) - http://www.borsosfi.hu, info@borsosfi.hu
|
2011-03-08 13:13:09 +00:00
|
|
|
'pl' => 'Polski', // Radosław Kowalewski - http://srsbiz.pl/
|
2010-10-15 14:39:18 +00:00
|
|
|
'ca' => 'Català', // Joan Llosas
|
2011-10-22 14:37:10 +00:00
|
|
|
'pt' => 'Português', // Gian Live - gian@live.com, Davi Alexandre davi@davialexandre.com.br
|
2011-02-03 20:56:30 +00:00
|
|
|
'sl' => 'Slovenski', // Matej Ferlan - www.itdinamik.com, matej.ferlan@itdinamik.com
|
2011-04-17 02:49:50 +00:00
|
|
|
'lt' => 'Lietuvių', // Paulius Leščinskas - http://www.lescinskas.lt
|
2011-02-08 18:57:06 +00:00
|
|
|
'tr' => 'Türkçe', // Bilgehan Korkmaz - turktron.com
|
2011-06-07 12:18:17 +00:00
|
|
|
'ro' => 'Limba Română', // .nick .messing - dot.nick.dot.messing@gmail.com
|
2009-07-02 15:21:16 +00:00
|
|
|
'ru' => 'Русский язык', // Maksim Izmaylov
|
2012-03-22 05:36:07 +00:00
|
|
|
'uk' => 'Українська', // Valerii Kryzhov
|
2009-08-21 10:38:49 +00:00
|
|
|
'zh' => '简体中文', // Mr. Lodar
|
|
|
|
'zh-tw' => '繁體中文', // http://tzangms.com
|
2010-04-25 07:25:55 +00:00
|
|
|
'ja' => '日本語', // Hitoshi Ozawa - http://sourceforge.jp/projects/oss-ja-jpn/releases/
|
2010-09-27 09:28:02 +00:00
|
|
|
'ta' => 'தமிழ்', // G. Sampath Kumar, Chennai, India, sampathkumar11@gmail.com
|
2010-11-10 16:30:34 +00:00
|
|
|
'ar' => 'العربية', // Y.M Amine - Algeria - nbr7@live.fr
|
2011-08-23 12:02:14 +00:00
|
|
|
'fa' => 'فارسی', // mojtaba barghbani - Iran - mbarghbani@gmail.com
|
2012-04-30 00:35:42 +00:00
|
|
|
'bn' => 'বাংলা', // Tanmay Sarkar - calcutta, India - tanmay@kisholoy.org
|
2007-07-17 14:04:29 +00:00
|
|
|
);
|
|
|
|
|
2010-12-30 12:53:39 +00:00
|
|
|
/** Get current language
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function get_lang() {
|
|
|
|
global $LANG;
|
|
|
|
return $LANG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Translate string
|
|
|
|
* @param string
|
|
|
|
* @param int
|
|
|
|
* @return string
|
|
|
|
*/
|
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];
|
2011-07-11 15:33:55 +00:00
|
|
|
if (is_array($translation)) {
|
2011-05-06 15:11:51 +00:00
|
|
|
$pos = ($number == 1 ? 0
|
2011-05-06 21:08:11 +00:00
|
|
|
: ($LANG == 'cs' || $LANG == 'sk' ? ($number && $number < 5 ? 1 : 2) // different forms for 1, 2-4, other
|
|
|
|
: ($LANG == 'fr' ? (!$number ? 0 : 1) // different forms for 0-1, other
|
2011-05-06 15:11:51 +00:00
|
|
|
: ($LANG == 'pl' ? ($number % 10 > 1 && $number % 10 < 5 && $number / 10 % 10 != 1 ? 1 : 2) // different forms for 1, 2-4, other
|
|
|
|
: ($LANG == 'sl' ? ($number % 100 == 1 ? 0 : ($number % 100 == 2 ? 1 : ($number % 100 == 3 || $number % 100 == 4 ? 2 : 3))) // different forms for 1, 2, 3-4, other
|
|
|
|
: ($LANG == 'lt' ? ($number % 10 == 1 && $number % 100 != 11 ? 0 : ($number % 10 > 1 && $number / 10 % 10 != 1 ? 1 : 2)) // different forms for 1, 12-19, other
|
2012-03-27 06:24:58 +00:00
|
|
|
: ($LANG == 'ru' || $LANG == 'uk' ? ($number % 10 == 1 && $number % 100 != 11 ? 0 : ($number % 10 > 1 && $number % 10 < 5 && $number / 10 % 10 != 1 ? 1 : 2)) // different forms for 1, 2-4, other
|
2011-05-06 15:11:51 +00:00
|
|
|
: 1
|
2012-03-27 06:24:58 +00:00
|
|
|
))))))); // http://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html
|
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);
|
2012-05-14 06:54:07 +00:00
|
|
|
return vsprintf(($translation !== null ? $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'));
|
2011-01-03 15:29:01 +00:00
|
|
|
echo lang('Language') . ": " . html_select("lang", $langs, $LANG, "var loc = location.search.replace(/[?&]lang=[^&]*/, ''); location.search = loc + (loc ? '&' : '') + 'lang=' + this.value;");
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|