root/trunk/wifidog-auth/wifidog/include/language.php @ 521

Revision 521, 1.7 KB (checked in by fproulx, 8 years ago)

Missing files

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2require_once BASEPATH.'classes/Session.php';
3$session = new Session();
4/* Gettext support */
5if(!function_exists ('gettext'))
6  {
7    define('GETTEXT_AVAILABLE', false);
8    /* Redefine the gettext functions if gettext isn't installed */
9    function gettext($string)
10    {
11      return $string;
12    }
13    function _($string)
14    {
15      return $string;
16    }
17  }
18else
19  {
20    define('GETTEXT_AVAILABLE', true);
21  }
22
23if (!empty($_REQUEST['lang'])) {
24    $session->set('SESS_LANGUAGE_VAR', $_REQUEST['lang']);
25}
26
27if ($session->get('SESS_LANGUAGE_VAR')) {
28    setlocale(LC_ALL, $session->get('SESS_LANGUAGE_VAR'));
29}
30
31if (GETTEXT_AVAILABLE) {
32        $current_locale = setlocale(LC_ALL, DEFAULT_LANG);
33        if (setlocale(LC_ALL, DEFAULT_LANG) != DEFAULT_LANG) {
34                echo "Warning: language.php: Unable to setlocale() to ".DEFAULT_LANG.", return value: $current_locale, current locale: ".  setlocale(LC_ALL, 0);
35        }
36
37        bindtextdomain('messages', BASEPATH.'/locale');
38        bind_textdomain_codeset('messages', 'UTF-8');
39        textDomain('messages');
40
41        if (!empty($_REQUEST['lang']) && isset($session)) {
42            $session->set(SESS_LANGUAGE_VAR, $_REQUEST['lang']);
43        }
44
45        if (isset($session) && $session->get(SESS_LANGUAGE_VAR)) {
46            putenv("LC_ALL=".$session->get(SESS_LANGUAGE_VAR));
47            putenv("LANGUAGE=".$session->get(SESS_LANGUAGE_VAR));
48            setlocale(LC_ALL, $session->get(SESS_LANGUAGE_VAR));
49            if (isset($smarty)) {
50                $smarty->assign("lang_id", $session->get(SESS_LANGUAGE_VAR));
51            }
52        } else {
53            putenv("LC_ALL=" . DEFAULT_LANG);
54            putenv("LANGUAGE=" . DEFAULT_LANG);
55            setlocale(LC_ALL, DEFAULT_LANG);
56            $smarty->assign("lang_id", DEFAULT_LANG);
57        }
58
59        if (isset($smarty)) {
60            $smarty->assign("lang_ids", $lang_ids);
61            $smarty->assign("lang_names", $lang_names);
62        }
63}
64?>
Note: See TracBrowser for help on using the browser.