Exemple #1
0
/**
 * Returns a localized message according to user preferred language.
 * @param string message to be translated
 * @return string translated message
 */
function lmessage($token)
{
    static $messages = null;
    if ($messages === null) {
        $lang = getPreferredLanguage();
        $msgFile = dirname(__FILE__) . "/messages-{$lang}.txt";
        if (!is_file($msgFile)) {
            $msgFile = dirname(__FILE__) . '/messages.txt';
        }
        if (($entries = @file($msgFile)) !== false) {
            foreach ($entries as $entry) {
                @(list($code, $message) = explode('=', $entry, 2));
                $messages[trim($code)] = trim($message);
            }
        }
    }
    return isset($messages[$token]) ? $messages[$token] : $token;
}
Exemple #2
0
/**
 * Returns a localized message according to user preferred language.
 * @param string message category
 * @param string message to be translated
 * @param array parameters to be applied to the translated message
 * @return string translated message
 */
function t($category, $message, $params = array())
{
    static $messages;
    if ($messages === null) {
        $messages = array();
        if (($lang = getPreferredLanguage()) !== false) {
            $file = dirname(__FILE__) . "/messages/{$lang}/yii.php";
            if (is_file($file)) {
                $messages = (include $file);
            }
        }
    }
    if (empty($message)) {
        return $message;
    }
    if (isset($messages[$message]) && $messages[$message] !== '') {
        $message = $messages[$message];
    }
    return $params !== array() ? strtr($message, $params) : $message;
}
Exemple #3
0
define('UPGRADE', 'upgrade');
// 升级完成
define('UPGRADED', 'upgraded');
// 备份数据
define('BACKUP', 'backup');
// 配置动作参数
define('CONFIG', 'config');
// 安装动作参数
define('INSTALL', 'install');
// 安装成功
define('INSTALLED', 'installed');
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : CHECK;
if (is_file("install.lock") && $action != UPGRADED && $action != INSTALLED) {
    header("location: ../index.php");
}
$lang = getPreferredLanguage();
$viewDir = dirname(__FILE__) . '/views/' . $lang . '/';
if (!is_dir($viewDir)) {
    $viewDir = dirname(__FILE__) . '/views/zh_cn/';
}
switch ($action) {
    case CHECK:
        $viewFile = $viewDir . 'check.php';
        $requirements = getRequirements();
        $dirRights = getDirRights($paths);
        renderFile($viewFile, array('requirements' => $requirements, 'dirRights' => $dirRights, 'checkResult' => getCheckResult($requirements, $dirRights)));
        break;
    case BACKUP:
        $viewFile = $viewDir . 'upgrade.php';
        list($dbhost, $dbname, $port, $dbuser, $dbpwd, $dbprefix) = getDBConfig(CONFIG_FILE);
        list($result, $info, $target, $con) = getDBCon($dbhost, $port, $dbuser, $dbpwd);