Example #1
0
function startup_gettext()
{
    # Get locale from Accept-Language header
    $lang = al2gt(array_keys(get_translations()), "text/html");
    if (defined('_TRANSLATION_OVERRIDE_DEFAULT')) {
        $lang = _TRANSLATION_OVERRIDE_DEFAULT;
    }
    if ($_SESSION["uid"] && get_schema_version() >= 120) {
        $pref_lang = get_pref("USER_LANGUAGE", $_SESSION["uid"]);
        if ($pref_lang && $pref_lang != 'auto') {
            $lang = $pref_lang;
        }
    }
    if ($lang) {
        if (defined('LC_MESSAGES')) {
            _setlocale(LC_MESSAGES, $lang);
        } else {
            if (defined('LC_ALL')) {
                _setlocale(LC_ALL, $lang);
            }
        }
        _bindtextdomain("messages", "locale");
        _textdomain("messages");
        _bind_textdomain_codeset("messages", "UTF-8");
    }
}
Example #2
0
function startup_gettext()
{
    # Get locale from Accept-Language header
    $lang = al2gt(array_keys(get_translations()), "text/html");
    if (defined('_TRANSLATION_OVERRIDE_DEFAULT')) {
        $lang = _TRANSLATION_OVERRIDE_DEFAULT;
    }
    /* In login action of mobile version */
    if ($_POST["language"] && defined('MOBILE_VERSION')) {
        $lang = $_POST["language"];
    } else {
        if ($_SESSION["language"] && $_SESSION["language"] != "auto") {
            $lang = $_SESSION["language"];
        }
    }
    if ($lang) {
        if (defined('LC_MESSAGES')) {
            _setlocale(LC_MESSAGES, $lang);
        } else {
            if (defined('LC_ALL')) {
                _setlocale(LC_ALL, $lang);
            }
        }
        if (defined('MOBILE_VERSION')) {
            _bindtextdomain("messages", "../locale");
        } else {
            _bindtextdomain("messages", "locale");
        }
        _textdomain("messages");
        _bind_textdomain_codeset("messages", "UTF-8");
    }
}
Example #3
0
function isInRelationship($uid = 27203077)
{
    global $yes, $no;
    $facebook = get_fb();
    $details = $facebook->api_client->users_getInfo($uid, array('name', 'relationship_status'));
    $gt = al2gt(array_keys($yes));
    $lang = $gt['lang'];
    $answer = $details[0]['relationship_status'] == "In a Relationship" ? $yes[$lang] : $no[$lang];
    return array('name' => $details[0]['name'], 'answer' => $answer);
}
Example #4
0
 function Template($title = null)
 {
     global $vbin;
     $this->Smarty();
     $this->template_dir = TEMPLATE_DIR;
     $this->compile_dir = CACHE_DIR . "/smarty/compiled/";
     $this->config_dir = TEMPLATE_DIR . "/configs/";
     $this->cache_dir = CACHE_DIR . "/smarty/cached/";
     $this->caching = false;
     $myLang = al2gt(array("en_CA.utf-8", "en_GB.utf-8", "en_US.utf-8", "fr_FR.utf-8", "fr_CA.utf-8", "de_DE.utf-8", "es_ES.utf-8", "ja_JP.utf-8"), "text/html");
     $myLangShort = substr($myLang, 0, 2);
     setlocale(LC_MESSAGES, $myLang);
     bindtextdomain("pastebin", "/web/devel.pastebin.ca/locale/");
     textdomain("pastebin");
     bind_textdomain_codeset("pastebin", "utf-8");
     if (empty($title)) {
         $title = _("General Pastebin");
     }
     $this->vbin =& $vbin;
     if (isset($this->vbin->id)) {
         $this->isVirtual = true;
     } else {
         $this->isVirtual = false;
         $this->vbin->setDefaultHost(isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"]);
     }
     $this->assign('virtual', $this->isVirtual);
     if (isset($this->vbin->private) && $this->vbin->private) {
         $this->isPrivate = true;
     } else {
         $this->isPrivate = false;
     }
     $this->assign('private', $this->isPrivate);
     $proto = isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on" ? 'https' : 'http';
     $this->assign('url', array('root' => $proto . '://' . $_SERVER["SERVER_NAME"], 'host' => isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : $_SERVER["SERVER_NAME"], 'css' => 'http://static.pastebin.ca/css', 'imgs' => 'http://static.pastebin.ca/imgs'));
     $this->assign('ssl', $proto == 'http' ? false : true);
     $this->assign('proto', $proto);
     $this->assign('lang', array('short' => $myLangShort, 'long' => $myLang));
     $this->assign('charset', 'UTF-8');
     $this->assign('recent', PasteUtil::getRecent());
     $this->assign('expiryOptions', array("" => _("Never"), "5 minutes" => _("5 minutes"), "10 minutes" => _("10 minutes"), "15 minutes" => _("15 minutes"), "30 minutes" => _("30 minutes"), "45 minutes" => _("45 minutes"), "1 hour" => _("1 hour"), "2 hours" => _("2 hours"), "4 hours" => _("4 hours"), "8 hours" => _("8 hours"), "12 hours" => _("12 hours"), "1 day" => _("1 day"), "2 days" => _("2 days"), "3 days" => _("3 days"), "1 week" => _("1 week"), "2 weeks" => _("2 weeks"), "3 weeks" => _("3 weeks"), "1 month" => _("1 month"), "2 months" => _("2 months"), "3 months" => _("3 months"), "4 months" => _("4 months"), "5 months" => _("5 months"), "6 months" => _("6 months"), "1 year" => _("1 year")));
     $this->assign('vbin', &$this->vbin);
     $this->assign('title', $title);
     if (isset($_SESSION) && isset($_SESSION['user']) && $_SESSION['user']['authed']) {
         $this->assign('user', array('authed' => true, 'id' => $_SESSION['user']['id'], 'username' => htmlentities($_SESSION['user']['username']), 'fullname' => htmlentities($_SESSION['user']['fullname']), 'nick' => htmlentities($_SESSION['user']['nick']), 'apikey' => htmlentities($_SESSION['user']['apikey']), 'prefs' => $_SESSION['user']['prefs'], 'adminLevel' => $_SESSION['user']['adminLevel'], 'timezone' => $_SESSION['user']['timezone']));
         putenv('TZ=' . $_SESSION['user']['timezone']);
     }
     $this->register_function('when', 'simpleDate', false, array('time'));
     $this->register_function('age', 'age', false, array('time', 'steps'));
     $this->register_block('dynamic', 'smarty_block_dynamic', false);
     $this->register_function('postkey', 'smarty_function_postkey', false);
     $this->register_function('postkeysig', 'smarty_function_postkeysig', false);
 }
Example #5
0
<?php

require_once "accept-to-gettext.inc";
$langs = array('it.ISO-8859-1', 'it.UTF-8', 'en_US.UTF-8', 'en_GB.UTF-8', 'en.UTF-8', 'en.ISO-8859-1', 'en_US.ISO-8859-1');
$locale = al2gt($langs, 'text/html');
if (substr($locale, 0, 2) == 'it') {
    include 'index.it.php';
} else {
    include 'index.en.php';
}