diff --git a/lang.inc.php b/lang.inc.php index db6416c9..9a5df947 100644 --- a/lang.inc.php +++ b/lang.inc.php @@ -1,13 +1,13 @@ array(), - 'cs' => array(), // Jakub Vrána - http://php.vrana.cz - 'sk' => array(), // Ivan Suchy - http://www.ivansuchy.com +static $langs = array( + 'en' => 'English', + 'cs' => 'Čeština', // Jakub Vrána - http://php.vrana.cz + 'sk' => 'Slovenčina', // Ivan Suchy - http://www.ivansuchy.com ); function lang($idf, $number = null) { global $LANG, $translations; - $translation = $translations[$LANG][$idf]; + $translation = $translations[$idf]; if (is_array($translation) && $translation) { switch ($LANG) { case 'cs': $pos = ($number == 1 ? 0 : (!$number || $number >= 5 ? 2 : 1)); break; @@ -22,24 +22,24 @@ function lang($idf, $number = null) { } function switch_lang() { - global $translations; + global $langs; echo "
" . lang('Language') . ":"; $base = remove_from_uri("lang"); - foreach ($translations as $lang => $val) { - echo ' $lang"; + foreach ($langs as $lang => $val) { + echo ' $lang"; } echo "
\n"; } if (isset($_GET["lang"])) { - setcookie("lang", $_GET["lang"], strtotime("+1 month"), preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"])); $_COOKIE["lang"] = $_GET["lang"]; $_SESSION["lang"] = $_GET["lang"]; } -if (isset($translations[$_COOKIE["lang"]])) { +if (isset($langs[$_COOKIE["lang"]])) { + setcookie("lang", $_GET["lang"], strtotime("+1 month"), preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"])); $LANG = $_COOKIE["lang"]; -} elseif (isset($translations[$_SESSION["lang"]])) { +} elseif (isset($langs[$_SESSION["lang"]])) { $LANG = $_SESSION["lang"]; } else { $accept_language = array(); @@ -50,12 +50,12 @@ if (isset($translations[$_COOKIE["lang"]])) { arsort($accept_language); $LANG = "en"; foreach ($accept_language as $lang => $q) { - if (isset($translations[$lang])) { + if (isset($langs[$lang])) { $LANG = $lang; break; } $lang = preg_replace('~-.*~', '', $LANG); - if (!isset($accept_language[$lang]) && isset($translations[$lang])) { + if (!isset($accept_language[$lang]) && isset($langs[$lang])) { $LANG = $lang; break; }