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 (
2018-01-14 10:03:54 +00:00
'en' => 'English' , // Jakub Vrána - https://www.vrana.cz
2013-06-03 17:00:16 +00:00
'ar' => 'العربية' , // Y.M Amine - Algeria - nbr7@live.fr
2015-11-01 19:33:04 +00:00
'bg' => 'Български' , // Deyan Delchev
2021-11-29 08:41:24 +00:00
'bn' => 'বাংলা' , // Dipak Kumar - dipak.ndc@gmail.com | Hossain Ahmed Saiman - hossain.ahmed@altscope.com
2016-02-01 17:10:07 +00:00
'bs' => 'Bosanski' , // Emir Kurtovic
2013-06-03 17:00:16 +00:00
'ca' => 'Català' , // Joan Llosas
2018-01-14 10:03:54 +00:00
'cs' => 'Čeština' , // Jakub Vrána - https://www.vrana.cz
2014-08-31 17:25:37 +00:00
'da' => 'Dansk' , // Jarne W. Beutnagel - jarne@beutnagel.dk
2008-05-15 14:38:15 +00:00
'de' => 'Deutsch' , // Klemens Häckel - http://clickdimension.wordpress.com
2015-09-20 18:06:40 +00:00
'el' => 'Ελληνικά' , // Dimitrios T. Tanis - jtanis@tanisfood.gr
2013-06-03 17:00:16 +00:00
'es' => 'Español' , // Klemens Häckel - http://clickdimension.wordpress.com
2008-09-01 09:35:51 +00:00
'et' => 'Eesti' , // Priit Kallas
2015-01-12 04:52:50 +00:00
'fa' => 'فارسی' , // mojtaba barghbani - Iran - mbarghbani@gmail.com, Nima Amini - http://nimlog.com
2016-02-06 18:50:57 +00:00
'fi' => 'Suomi' , // Finnish - Kari Eveli - http://www.lexitec.fi/
2013-06-03 17:00:16 +00:00
'fr' => 'Français' , // Francis Gagné, Aurélien Royer
2015-09-20 18:24:28 +00:00
'gl' => 'Galego' , // Eduardo Penabad Ramos
2017-09-09 10:06:14 +00:00
'he' => 'עברית' , // Binyamin Yawitz - https://stuff-group.com/
2010-10-07 14:03:22 +00:00
'hu' => 'Magyar' , // Borsos Szilárd (Borsosfi) - http://www.borsosfi.hu, info@borsosfi.hu
2013-06-03 17:00:16 +00:00
'id' => 'Bahasa Indonesia' , // Ivan Lanin - http://ivan.lanin.org
'it' => 'Italiano' , // Alessandro Fiorotto, Paolo Asperti
'ja' => '日本語' , // Hitoshi Ozawa - http://sourceforge.jp/projects/oss-ja-jpn/releases/
2018-09-18 13:34:09 +00:00
'ka' => 'ქართული' , // Saba Khmaladze skhmaladze@uglt.org
2013-06-03 17:00:16 +00:00
'ko' => '한국어' , // dalli - skcha67@gmail.com
'lt' => 'Lietuvių' , // Paulius Leščinskas - http://www.lescinskas.lt
2018-01-28 08:00:52 +00:00
'ms' => 'Bahasa Melayu' , // Pisyek
2013-06-03 17:00:16 +00:00
'nl' => 'Nederlands' , // Maarten Balliauw - http://blog.maartenballiauw.be
2014-04-13 17:42:24 +00:00
'no' => 'Norsk' , // Iver Odin Kvello, mupublishing.com
2011-03-08 13:13:09 +00:00
'pl' => 'Polski' , // Radosław Kowalewski - http://srsbiz.pl/
2013-12-20 23:06:11 +00:00
'pt' => 'Português' , // André Dias
2014-03-08 18:15:41 +00:00
'pt-br' => 'Português (Brazil)' , // Gian Live - gian@live.com, Davi Alexandre davi@davialexandre.com.br, RobertoPC - http://www.robertopc.com.br
2011-06-07 12:18:17 +00:00
'ro' => 'Limba Română' , // .nick .messing - dot.nick.dot.messing@gmail.com
2017-04-01 18:59:20 +00:00
'ru' => 'Русский' , // Maksim Izmaylov; Andre Polykanine - https://github.com/Oire/
2013-06-03 17:00:16 +00:00
'sk' => 'Slovenčina' , // Ivan Suchy - http://www.ivansuchy.com, Juraj Krivda - http://www.jstudio.cz
'sl' => 'Slovenski' , // Matej Ferlan - www.itdinamik.com, matej.ferlan@itdinamik.com
2012-09-01 15:47:29 +00:00
'sr' => 'Српски' , // Nikola Radovanović - cobisimo@gmail.com
2019-10-02 18:11:04 +00:00
'sv' => 'Svenska' , // rasmusolle - https://github.com/rasmusolle
2013-06-03 17:00:16 +00:00
'ta' => 'தமிழ்' , // G. Sampath Kumar, Chennai, India, sampathkumar11@gmail.com
2018-01-22 12:51:47 +00:00
'th' => 'ภาษาไทย' , // Panya Saraphi, elect.tu@gmail.com - http://www.opencart2u.com/
2013-06-03 17:00:16 +00:00
'tr' => 'Türkçe' , // Bilgehan Korkmaz - turktron.com
'uk' => 'Українська' , // Valerii Kryzhov
2014-04-13 17:42:24 +00:00
'vi' => 'Tiếng Việt' , // Giang Manh @ manhgd google mail
2014-01-08 07:20:08 +00:00
'zh' => '简体中文' , // Mr. Lodar, vea - urn2.net - vea.urn2@gmail.com
2009-08-21 10:38:49 +00:00
'zh-tw' => '繁體中文' , // http://tzangms.com
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 ;
2012-09-03 22:59:05 +00:00
$translation = ( $translations [ $idf ] ? $translations [ $idf ] : $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
2016-02-01 17:10:07 +00:00
: ( $LANG == 'pl' ? ( $number % 10 > 1 && $number % 10 < 5 && $number / 10 % 10 != 1 ? 1 : 2 ) // different forms for 1, 2-4 except 12-14, other
2011-05-06 15:11:51 +00:00
: ( $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
2016-02-01 17:10:07 +00:00
: ( $LANG == 'bs' || $LANG == 'ru' || $LANG == 'sr' || $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 except 11, 2-4 except 12-14, other
2015-09-20 18:06:40 +00:00
: 1 // different forms for 1, other
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-06-05 00:44:04 +00:00
$format = str_replace ( " %d " , " %s " , $translation );
if ( $format != $translation ) {
2014-03-20 04:56:42 +00:00
$args [ 0 ] = format_number ( $number );
2012-06-05 00:44:04 +00:00
}
return vsprintf ( $format , $args );
2007-07-05 10:46:44 +00:00
}
function switch_lang () {
2012-09-22 13:22:44 +00:00
global $LANG , $langs ;
2012-09-07 06:32:42 +00:00
echo " <form action='' method='post'> \n <div id='lang'> " ;
2012-09-07 06:07:31 +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 " ;
2013-10-25 02:10:50 +00:00
echo " <input type='hidden' name='token' value=' " . get_token () . " '> \n " ; // $token may be empty in auth.inc.php
2009-10-02 13:21:34 +00:00
echo " </div> \n </form> \n " ;
2007-07-05 10:46:44 +00:00
}
2013-10-25 02:10:50 +00:00
if ( isset ( $_POST [ " lang " ]) && verify_token ()) { // $error not yet available
2012-09-07 06:32:42 +00:00
cookie ( " adminer_lang " , $_POST [ " lang " ]);
$_SESSION [ " lang " ] = $_POST [ " lang " ]; // cookies may be disabled
2012-09-16 13:08:00 +00:00
$_SESSION [ " translations " ] = array (); // used in compiled version
2012-09-07 06:32:42 +00:00
redirect ( remove_from_uri ());
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
}
}
}