示例#1
0
function set_timezone($lang = '')
{
    if (empty($lang)) {
        return array('UTC', 0);
    }
    $l = accept_language::split_locale_str($lang);
    // When the name of a country is uncertain (国名が不明な場合)
    if (empty($l[2])) {
        $obj_l2c = new lang2country();
        $l[2] = $obj_l2c->get_lang2country($l[1]);
        if (empty($l[2])) {
            return array('UTC', 0);
        }
    }
    $obj = new timezone();
    $obj->set_datetime(UTIME);
    // Setting at judgment time. (判定時刻の設定)
    $obj->set_country($l[2]);
    // The acquisition country is specified. (取得国を指定)
    // With the installation country in case of the same
    // 設置者の国と同一の場合
    if ($lang == DEFAULT_LANG) {
        if (defined('DEFAULT_TZ_NAME')) {
            $obj->set_tz_name(DEFAULT_TZ_NAME);
        }
    }
    list($zone, $zonetime) = $obj->get_zonetime();
    if ($zonetime == 0 || empty($zone)) {
        return array('UTC', 0);
    }
    return array($zone, $zonetime);
}
示例#2
0
/**
 * Plug-in that achieves gettext in PukiWiki page
 * PukiWiki ページ内で gettext を実現するプラグイン
 *
 * @copyright   Copyright &copy; 2005-2006, Katsumi Saito <*****@*****.**>
 * @version     $Id: _.inc.php,v 0.10 2006/02/04 23:42:00 upk Exp $
 * @license     http://opensource.org/licenses/gpl-license.php GNU Public License
 *
 * o :config/i18n/text/ja/text or :config/i18n/text/ja_JP is acceptable.
 * o There are zh_TW etc. ,
 *   too and the form of language_country can be selected though the language name is appropriate in principle.
 * o 原則的には、言語名が適切であるものの、zh_TW などもあり 言語_国 の形式も選択可能。
 *
 * o &_(ja){掲示板};
 *   一度、英語の文字列を得て、表示言語に変換する。
 * o &_{BBS};
 *   英語表記であることを信じ、表示言語に変換する。
 *
 * 全てにおいて、未定義語の場合は、指定文字列をそのまま戻す。
 * All, a specified character string is returned as it is for an undefined word.
 *
 */
function plugin___inline()
{
    global $language_considering_setting_level;
    global $language;
    global $i18n_temp_msg;
    switch (func_num_args()) {
        case 1:
            list($msg) = func_get_args();
            // $parm_lang = DEFAULT_LANG;
            $parm_lang = 'en_US';
            break;
        default:
            list($parm_lang, $msg) = func_get_args();
    }
    $msg = strip_htmltag($msg);
    // FIXME: level 5
    $view_lang = $language_considering_setting_level == 0 ? get_language(5) : $language;
    $view_lang_split = accept_language::split_locale_str($view_lang);
    // ja_JP なら ja に分割
    if ($parm_lang == $view_lang || $parm_lang == $view_lang_split[1]) {
        return $msg;
    }
    // 指定言語と同じ
    // 指定文字列が en 以外の場合は、ベース言語に変換後、他言語に変換する
    $parm_lang_split = accept_language::split_locale_str($parm_lang);
    if (isset($i18n_temp_msg)) {
        $temp_msg = i18n_TempMsg($parm_lang_split, $view_lang_split, $msg);
        if (!empty($temp_msg)) {
            return $temp_msg;
        }
    }
    if ($parm_lang_split[1] !== 'en') {
        $msg = i18n_ConfMsgGet($parm_lang_split, $msg, 1);
    }
    // :config から、単語を検索
    return i18n_ConfMsgGet($view_lang_split, $msg);
}
示例#3
0
 function split_str($env, $conv = TRUE, $sort = TRUE)
 {
     $rc = array();
     foreach (split(',', $env) as $x) {
         $x1 = split(';', $x);
         // '',1 の '' は、DUMMY
         $q = count($x1) == 1 ? array('', 1) : split('=', $x1[1]);
         if ($conv) {
             $l = accept_language::split_locale_str($x1[0]);
             $rc[] = array($l[0], $q[1]);
         } else {
             $rc[] = array($x1[0], $q[1]);
         }
     }
     if ($sort) {
         usort($rc, create_function('$a,$b', 'return ($a[1] == $b[1]) ? 0 : (($a[1] > $b[1]) ? -1 : 1);'));
     }
     return $rc;
 }
function plugin_multilang_accept($lang)
{
    global $language_considering_setting_level;
    global $language;
    // FIXME: level 5
    $env = $language_considering_setting_level == 0 ? get_language(5) : $language;
    $l = accept_language::split_locale_str($env);
    return $lang == $env || $lang == $l[1];
}