当前位置: 首页>>代码示例>>PHP>>正文


PHP l10n::init方法代码示例

本文整理汇总了PHP中l10n::init方法的典型用法代码示例。如果您正苦于以下问题:PHP l10n::init方法的具体用法?PHP l10n::init怎么用?PHP l10n::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在l10n的用法示例。


在下文中一共展示了l10n::init方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 /**
  * Load the translation strings
  *
  * @access public
  * @author Jerome Bogaerts, <jerome.bogaerts@tudor.lu>
  * @param  common_ext_Extension $extension
  * @param  string langCode
  * @return mixed
  */
 public static function init(common_ext_Extension $extension, $langCode)
 {
     // if the langCode is empty do nothing
     if (empty($langCode)) {
         throw new Exception("Language is not defined");
     }
     //init the ClearFw l10n tools
     l10n::init();
     $basePath = $extension->getDir();
     if (!empty($_GET['ext']) && is_string($_GET['ext'])) {
         $shownExtension = common_ext_ExtensionsManager::singleton()->getExtensionById($_GET['ext']);
         if (!empty($shownExtension)) {
             try {
                 $basePath = $shownExtension->getDir();
                 $baseUrl = $shownExtension->getConstant('BASE_URL');
             } catch (common_exception_Error $e) {
                 // let the current base path be used...
             }
         }
     }
     l10n::set($basePath . 'locales' . DIRECTORY_SEPARATOR . $langCode . DIRECTORY_SEPARATOR . 'messages');
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:31,代码来源:class.I18n.php

示例2: HttpRequest

# Manage the current language selected
$lang = $GLOBALS['lang'];
# Not really used because the anonymous account is always used
if (Auth::isAuth()) {
    $lang = Auth::getLanguage();
    # Special case to add synchro for changing temporary langue via the top control panel
    $re = new HttpRequest();
    $module = $re->getModule();
    $action = $re->getAction();
    if ($module == 'wall' && $action == 'index') {
        $args = $re->getArgs();
        if (isset($args['langage'])) {
            $availableLanguages = Util::getAvailableLanguages();
            if ($args['langage'] !== null && in_array($args['langage'], array_keys($availableLanguages))) {
                $_SESSION['globalLangage'] = $lang = $args['langage'];
            }
        }
    }
}
// internationalisation
l10n::init();
l10n::set(dirname(__FILE__) . '/locales/' . $lang . '/messages');
try {
    $re = new HttpRequest();
    $fc = new AdminEnabledDefaultFC($re);
    $fc->loadModule();
} catch (Exception $e) {
    $message = $e;
    header('HTTP/1.1 500 Internal Error');
    require_once DIR_VIEWS . $GLOBALS['dir_theme'] . "error404.tpl";
}
开发者ID:ripplecrpht,项目名称:ripplecrpht,代码行数:31,代码来源:index.php

示例3: define

#  ClearBricks and DotClear classes auto-loader
if (@is_dir('/usr/lib/clearbricks')) {
    define('CLEARBRICKS_PATH', '/usr/lib/clearbricks');
} elseif (is_dir(dirname(__FILE__) . '/../../inc/libs/clearbricks')) {
    define('CLEARBRICKS_PATH', dirname(__FILE__) . '/../../inc/libs/clearbricks');
} elseif (isset($_SERVER['CLEARBRICKS_PATH']) && is_dir($_SERVER['CLEARBRICKS_PATH'])) {
    define('CLEARBRICKS_PATH', $_SERVER['CLEARBRICKS_PATH']);
}
if (!defined('CLEARBRICKS_PATH') || !is_dir(CLEARBRICKS_PATH)) {
    exit('No clearbricks path defined');
}
require CLEARBRICKS_PATH . '/_common.php';
# Loading locales for detected language
$dlang = http::getAcceptLanguage();
if ($dlang != 'en') {
    l10n::init($dlang);
    l10n::set(dirname(__FILE__) . '/../../locales/' . $dlang . '/main');
}
if (is_file(DC_RC_PATH)) {
    http::redirect('index.php');
}
if (!is_writable(dirname(DC_RC_PATH))) {
    $err = '<p>' . sprintf(__('Path <strong>%s</strong> is not writable.'), path::real(dirname(DC_RC_PATH))) . '</p>' . '<p>' . __('Dotclear installation wizard could not create configuration file for you. ' . 'You must change folder right or create the <strong>config.php</strong> ' . 'file manually, please refer to ' . '<a href="http://dotclear.org/documentation/2.0/admin/install">' . 'the documentation</a> to learn how to do this.') . '</p>';
}
$DBDRIVER = !empty($_POST['DBDRIVER']) ? $_POST['DBDRIVER'] : (function_exists('mysqli_connect') ? 'mysqli' : 'mysql');
$DBHOST = !empty($_POST['DBHOST']) ? $_POST['DBHOST'] : '';
$DBNAME = !empty($_POST['DBNAME']) ? $_POST['DBNAME'] : '';
$DBUSER = !empty($_POST['DBUSER']) ? $_POST['DBUSER'] : '';
$DBPASSWORD = !empty($_POST['DBPASSWORD']) ? $_POST['DBPASSWORD'] : '';
$DBPREFIX = !empty($_POST['DBPREFIX']) ? $_POST['DBPREFIX'] : 'dc_';
if (!empty($_POST)) {
开发者ID:nikrou,项目名称:dotclear,代码行数:31,代码来源:wizard.php

示例4: editPreferences

 public function editPreferences()
 {
     // Note : because the number of parameters may vary in the future,
     // I will use $_POST to retrieve request params.
     $currentUser = Auth::getUserName();
     // -- Identifiers.
     $oldPassword = $_POST['old_password'];
     $newPassword = $_POST['new_password'];
     $confirmPassword = $_POST['new_password_confirm'];
     // OpenId
     $openId = isset($_POST['openid']) ? $_POST['openid'] : '';
     // -- I18n.
     $language = $_POST['language'];
     try {
         UsersManagement::updatePreferences(array('old_password' => $oldPassword, 'new_password' => $newPassword, 'confirm_password' => $confirmPassword, 'language' => $language, 'openid' => $openId, 'username' => $currentUser, 'userid' => Auth::getUserId()));
         // Don't forget to change the language before generating the message to
         // the user.
         $GLOBALS['lang'] = $language;
         l10n::init();
         l10n::set(dirname(__FILE__) . '/../locales/' . $GLOBALS['lang'] . '/messages');
         $_SESSION['isError'] = false;
         $_SESSION['message'] = __("Your preferences were successfuly changed.");
     } catch (PreferencesException $e) {
         $_SESSION['isError'] = true;
         $_SESSION['message'] = '';
         switch ($e->getCode()) {
             case PreferencesException::WRONG_OLD_PASSWORD:
                 $_SESSION['message'] = __("Wrong old password. Please try again.");
                 break;
             case PreferencesException::NEW_PASSWORD_TOO_SHORT:
                 $_SESSION['message'] = sprintf(__("The new password you provided is too short and must be at least composed of %s characters."), PASSWORDS_MIN_LENGTH);
                 break;
             case PreferencesException::NEW_PASSWORDS_DIFFERENT:
                 $_SESSION['message'] = __("The new and confirmation passwords are different. Please try again.");
                 break;
         }
     }
     DefaultFC::redirection('users/preferences');
 }
开发者ID:ripplecrpht,项目名称:ripplecrpht,代码行数:39,代码来源:Users.class.php


注:本文中的l10n::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。