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


PHP I18n类代码示例

本文整理汇总了PHP中I18n的典型用法代码示例。如果您正苦于以下问题:PHP I18n类的具体用法?PHP I18n怎么用?PHP I18n使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getTargetPageId

 /**
  * Parses a specified page ID and redirects to another ID if required.
  * 
  * @param WebSoccer $websoccer Website context.
  * @param I18n $i18n messages provider.
  * @param string $requestedPageId unfiltered Page ID that has been requested.
  * @return string target page ID to display.
  */
 public static function getTargetPageId(WebSoccer $websoccer, I18n $i18n, $requestedPageId)
 {
     $pageId = $requestedPageId;
     // set default page ID
     if ($pageId == NULL) {
         $pageId = DEFAULT_PAGE_ID;
     }
     // redirect to log-in form if website is generally protected
     $user = $websoccer->getUser();
     if ($websoccer->getConfig('password_protected') && $user->getRole() == ROLE_GUEST) {
         // list of page IDs that needs to be excluded.
         $freePageIds = array(LOGIN_PAGE_ID, 'register', 'register-success', 'activate-user', 'forgot-password', 'imprint', 'logout', 'termsandconditions');
         if (!$websoccer->getConfig('password_protected_startpage')) {
             $freePageIds[] = DEFAULT_PAGE_ID;
         }
         if (!in_array($pageId, $freePageIds)) {
             // create warning message
             $websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_WARNING, $i18n->getMessage('requireslogin_box_title'), $i18n->getMessage('requireslogin_box_message')));
             $pageId = LOGIN_PAGE_ID;
         }
     }
     // exception rule: If user clicks at breadcrumb navigation on team details, there will be no ID given, so redirect to leagues
     if ($pageId == 'team' && $websoccer->getRequestParameter('id') == null) {
         $pageId = 'leagues';
     }
     // prompt user to enter user name, after he has been created without user name (e.g. by a custom LoginMethod).
     if ($user->getRole() == ROLE_USER && !strlen($user->username)) {
         $pageId = ENTERUSERNAME_PAGE_ID;
     }
     return $pageId;
 }
开发者ID:astroChasqui,项目名称:open-websoccer,代码行数:39,代码来源:PageIdRouter.class.php

示例2: formatCompactAddress

 public static function formatCompactAddress($data, $locale = null)
 {
     if (!isset($locale)) {
         $locale = Locale::getLocale();
     }
     $i18n = new I18n();
     return self::_formatAddress($i18n->getAddressFormat($locale), $data, ' - ');
 }
开发者ID:jnadaud,项目名称:solenoid,代码行数:8,代码来源:String.php

示例3: forceClearance

 public static function forceClearance($roles, $user, $params = array(), $error = 'error.insufficient_rights')
 {
     $app_url = Settings::getProtected('app_url');
     $i18n = new I18n("../translations", Settings::getProtected('language'));
     if (!self::verify($roles, $user, $params)) {
         Utils::redirectToDashboard('', $i18n->t($error));
         return false;
     }
     return true;
 }
开发者ID:hmmbug,项目名称:unbindery,代码行数:10,代码来源:RoleController.class.php

示例4: readMetadata

 /**
  * Read Metadata from xml array
  * @param array $xmlArr
  */
 protected function readMetadata(&$xmlArr)
 {
     parent::readMetaData($xmlArr);
     $this->m_InheritFrom = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["INHERITFROM"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["INHERITFROM"] : null;
     $this->m_Title = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["TITLE"]) ? I18n::getInstance()->translate($xmlArr["BIZFORM"]["ATTRIBUTES"]["TITLE"]) : null;
     $this->m_Description = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["DESCRIPTION"]) ? I18n::getInstance()->translate($xmlArr["BIZFORM"]["ATTRIBUTES"]["DESCRIPTION"]) : null;
     //added by Jixian
     $this->m_SearchRule = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["SEARCHRULE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["SEARCHRULE"] : null;
     $this->m_BaseSearchRule = $this->m_SearchRule;
     $this->m_jsClass = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["JSCLASS"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["JSCLASS"] : null;
     $this->m_Height = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["HEIGHT"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["HEIGHT"] : null;
     $this->m_Width = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["WIDTH"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["WIDTH"] : null;
     $this->m_Range = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["PAGESIZE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["PAGESIZE"] : null;
     $this->m_FullPage = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["FULLPAGE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["FULLPAGE"] : null;
     $this->m_Stateless = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["STATELESS"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["STATELESS"] : null;
     $this->m_Style = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["STYLE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["STYLE"] : 'display: block';
     //Get the style of a form from xml --jmmz
     $this->m_Name = $this->prefixPackage($this->m_Name);
     $this->m_DataObjName = $this->prefixPackage($xmlArr["BIZFORM"]["ATTRIBUTES"]["BIZDATAOBJ"]);
     $this->m_DisplayModes = new MetaIterator($xmlArr["BIZFORM"]["DISPLAYMODES"]["MODE"], "DisplayMode");
     $this->m_RecordRow = new RecordRow($xmlArr["BIZFORM"]["BIZCTRLLIST"]["BIZCTRL"], "FieldControl", $this);
     $this->m_ToolBar = new ToolBar($xmlArr["BIZFORM"]["TOOLBAR"]["CONTROL"], "HTMLControl", $this);
     $this->m_NavBar = new NavBar($xmlArr["BIZFORM"]["NAVBAR"]["CONTROL"], "HTMLControl", $this);
     $this->m_Parameters = new MetaIterator($xmlArr["BIZFORM"]["PARAMETERS"]["PARAMETER"], "Parameter");
 }
开发者ID:que273,项目名称:siremis,代码行数:29,代码来源:BizForm_Abstract.php

示例5: before

 public function before()
 {
     parent::before();
     // Borrowed from userguide
     if (isset($_GET['lang'])) {
         $lang = $_GET['lang'];
         // Make sure the translations is valid
         $translations = Kohana::message('langify', 'translations');
         if (in_array($lang, array_keys($translations))) {
             // Set the language cookie
             Cookie::set('langify_language', $lang, Date::YEAR);
         }
         // Reload the page
         $this->request->redirect($this->request->uri());
     }
     // Set the translation language
     I18n::$lang = Cookie::get('langify_language', Kohana::config('langify')->lang);
     // Borrowed from Vendo
     // Automaticly load a view class based on action.
     $view_name = $this->view_prefix . Request::current()->action();
     if (Kohana::find_file('classes', strtolower(str_replace('_', '/', $view_name)))) {
         $this->view = new $view_name();
         $this->view->set('version', $this->version);
     }
 }
开发者ID:Hinton,项目名称:langify,代码行数:25,代码来源:base.php

示例6: init

 /**
  * Application initialization
  *     - Loads the plugins
  *     - Sets the cookie configuration
  */
 public static function init()
 {
     // Set defaule cache configuration
     Cache::$default = Kohana::$config->load('site')->get('default_cache');
     try {
         $cache = Cache::instance()->get('dummy' . rand(0, 99));
     } catch (Exception $e) {
         // Use the dummy driver
         Cache::$default = 'dummy';
     }
     // Load the plugins
     Swiftriver_Plugins::load();
     // Add the current default theme to the list of modules
     $theme = Swiftriver::get_setting('site_theme');
     if (isset($theme) and $theme != "default") {
         Kohana::modules(array_merge(array('themes/' . $theme->value => THEMEPATH . $theme->value), Kohana::modules()));
     }
     // Clean up
     unset($active_plugins, $theme);
     // Load the cookie configuration
     $cookie_config = Kohana::$config->load('cookie');
     Cookie::$httponly = TRUE;
     Cookie::$salt = $cookie_config->get('salt', Swiftriver::DEFAULT_COOKIE_SALT);
     Cookie::$domain = $cookie_config->get('domain') or '';
     Cookie::$secure = $cookie_config->get('secure') or FALSE;
     Cookie::$expiration = $cookie_config->get('expiration') or 0;
     // Set the default site locale
     I18n::$lang = Swiftriver::get_setting('site_locale');
 }
开发者ID:aliyubash23,项目名称:SwiftRiver,代码行数:34,代码来源:Swiftriver.php

示例7: get_available_langs

 public function get_available_langs()
 {
     $langs = I18n::available_langs();
     $system_default = Arr::get($langs, Config::get('site', 'default_locale'));
     $langs[Model_User::DEFAULT_LOCALE] = __('System default (:locale)', array(':locale' => $system_default));
     return $langs;
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:7,代码来源:profile.php

示例8: runlevel3

 private static function runlevel3(){
     Logger::enter_group('Runlevel 4');
     Logger::debug('Loading Application-Variables');
     require_once(APP_ROOT . '/defaults.php');
     I18n::load();
     Logger::leave_group();
 }
开发者ID:reddragon010,项目名称:RG-ServerPanel,代码行数:7,代码来源:Bootloader.php

示例9: getDefaultLangName

 public function getDefaultLangName($lang = null)
 {
     if ($lang == null) {
         $do = BizSystem::getObject("myaccount.do.PreferenceDO", 1);
         $rec = $do->fetchOne("[user_id]='0' AND [name]='language'");
         if ($rec) {
             $lang = $rec['value'];
         } else {
             $lang = DEFAULT_LANGUAGE;
         }
     }
     $current_locale = I18n::getCurrentLangCode();
     require_once 'Zend/Locale.php';
     $locale = new Zend_Locale($current_locale);
     $display_name = Zend_Locale::getTranslation($lang, 'language', $locale);
     if ($display_name) {
         return $display_name;
     } else {
         if ($lang) {
             return $lang;
         } else {
             return DEFAULT_LANGUAGE;
         }
     }
 }
开发者ID:Why-Not-Sky,项目名称:cubi-ng,代码行数:25,代码来源:localeService.php

示例10: before

 public function before()
 {
     parent::before();
     I18n::lang('ru');
     Cookie::$salt = 'eqw67dakbs';
     Session::$default = 'cookie';
     //$this->cache = Cache::instance('file');
     $this->session = Session::instance();
     $this->auth = Auth::instance();
     $this->user = $this->auth->get_user();
     //  $captcha = Captcha::instance();
     // Подключаем стили и скрипты
     $this->template->styles = array();
     $this->template->scripts = array();
     //Вывод в шаблон
     $this->template->title = null;
     $this->template->site_name = null;
     $this->template->description = null;
     $this->template->page_title = null;
     //Подключаем главный шаблон
     $this->template->main = null;
     $this->template->userarea = null;
     $this->template->top_menu = View::factory('v_top_menu');
     $this->template->manufactures = null;
     $this->template->left_categories = null;
     $this->template->slider_banner = null;
     $this->template->block_left = array();
     $this->template->block_center = array();
     $this->template->block_right = array();
     $this->template->block_footer = null;
 }
开发者ID:raku,项目名称:mykohana,代码行数:31,代码来源:base.php

示例11: Index

 public function Index()
 {
     if ($this->request->isPost()) {
         if (Config::$authentication['authentication']) {
             $server = isset(Config::$server['server']) && !empty(Config::$server['server']) ? Config::$server['server'] : Config::$server['host'] . ':' . Config::$server['port'];
             $db = $this->request->getParam('db');
             $options = array('username' => $this->request->getParam('username'), 'password' => $this->request->getParam('password'), 'db' => !empty($db) ? $db : 'admin');
             $mongo = PHPMongoDB::getInstance($server, $options);
             if ($mongo->getConnection()) {
                 $seesion = Application::getInstance('Session');
                 $seesion->isLogedIn = TRUE;
                 $seesion->server = $server;
                 $seesion->options = $options;
                 $this->request->redirect(Theme::URL('Index/Index'));
             } else {
                 $this->message->error = $mongo->getExceptionMessage();
             }
         } else {
             if ($this->request->getParam('username') == Config::$authentication['user'] && $this->request->getParam('password') == Config::$authentication['password']) {
                 $server = isset(Config::$server['server']) && !empty(Config::$server['server']) ? Config::$server['server'] : Config::$server['host'] . ':' . Config::$server['port'];
                 $seesion = Application::getInstance('Session');
                 $seesion->isLogedIn = TRUE;
                 $seesion->server = $server;
                 $seesion->options = array();
                 $this->request->redirect(Theme::URL('Index/Index'));
             } else {
                 $this->message->error = I18n::t('AUTH_FAIL');
             }
         }
     }
     $data = array();
     $this->display('index', $data);
 }
开发者ID:andrewyang96,项目名称:phpmongodb,代码行数:33,代码来源:Login.php

示例12: setup

 public static function setup()
 {
     language::$available_languages = Kohana::config('locale.languages');
     if (Router::$language === NULL) {
         $redirect = NULL;
         if (empty(Router::$current_uri)) {
             if (($lang = language::browser_language()) !== '') {
                 $redirect = $lang;
             } else {
                 reset(language::$available_languages);
                 $redirect = key(language::$available_languages);
             }
         } else {
             if (($lang = language::browser_language()) !== '') {
                 $redirect = $lang . '/' . Router::$current_uri;
             } else {
                 reset(language::$available_languages);
                 $redirect = key(language::$available_languages) . '/' . Router::$current_uri;
             }
         }
         url::redirect($redirect);
     }
     Kohana::config_set('locale.language', language::$available_languages[Router::$language]['language']);
     I18n::$lang = language::$available_languages[Router::$language]['language'][0];
 }
开发者ID:googlecode-mirror,项目名称:s7ncms,代码行数:25,代码来源:language.php

示例13: before

 public function before()
 {
     parent::before();
     $lang = $this->request->param('lang');
     // Make sure we have a valid language
     if (!in_array($lang, array_keys(Kohana::config('kohana')->languages))) {
         $this->request->action = 'error';
         throw new Kohana_Request_Exception('Unable to find a route to match the URI: :uri (specified language was not found in config)', array(':uri' => $this->request->uri));
     }
     I18n::$lang = $lang;
     if (isset($this->page_titles[$this->request->action])) {
         // Use the defined page title
         $title = $this->page_titles[$this->request->action];
     } else {
         // Use the page name as the title
         $title = ucwords(str_replace('_', ' ', $this->request->action));
     }
     $this->template->title = $title;
     if (!kohana::find_file('views', 'pages/' . $this->request->action)) {
         $this->request->action = 'error';
     }
     $this->template->content = View::factory('pages/' . $this->request->action);
     $this->template->set_global('request', $this->request);
     $this->template->meta_tags = array();
 }
开发者ID:bluehawk,项目名称:kohanaphp.com,代码行数:25,代码来源:page.php

示例14: setLanguage

 /**
  * string setLanguage(string $lang = "")
  *
  * Sets a language to locale options
  *
  * @param string $lang (optional)
  * @return string new language setted
  * @access public
  * @static
  * @see OPEN_LANG_DEFAULT
  */
 public static function setLanguage($lang = "")
 {
     $newLang = OPEN_LANG_DEFAULT;
     if (empty($lang)) {
         // Detect Browser Language
         if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
             $language = explode(",", $_SERVER["HTTP_ACCEPT_LANGUAGE"]);
             $langPieces = explode("-", $language[0]);
             if (strlen($language[0]) == 2) {
                 $browserLanguage = $language[0] . "_" . strtoupper($language[0]);
             } else {
                 $browserLanguage = strtolower($langPieces[0]) . "_" . strtoupper($langPieces[1]);
             }
             if (self::languageExists($browserLanguage)) {
                 $newLang = $browserLanguage;
             }
         }
     } else {
         if (self::languageExists($lang)) {
             $newLang = $lang;
         }
     }
     putenv("LANG=" . $newLang);
     //setlocale(LC_ALL, $newLang);
     $nls = I18n::getNLS();
     if (defined("PHP_OS") && preg_match("/win/i", PHP_OS)) {
         setlocale(LC_ALL, isset($nls['win32'][$newLang]) ? $nls['win32'][$newLang] : $newLang);
     } else {
         setlocale(LC_ALL, $newLang);
     }
     return $newLang;
 }
开发者ID:edubort,项目名称:openclinic,代码行数:43,代码来源:I18n.php

示例15: getContent

 protected function getContent()
 {
     $content = '<ol class="breadcrumb">
               <li><a href="' . ROOT_DIR . 'admin/courseadmin">' . I18n::t('courseoverview.title') . '</a></li>
               <li><a href="' . ROOT_DIR . 'admin/lessonadmin/' . $this->course->getId() . '">' . $this->course->getName(I18n::getLang()) . '</a></li>
               <li class="active">' . $this->lesson->getName(I18n::getLang()) . '</li>
             </ol>';
     $content .= '<form method="post"><input type="hidden" name="action" value="saveExercises" />
 <table id="exercise-admin-table" class="table table-hover">
 <thead>
 <tr>
 <th>' . I18n::t('admin.exerciseadmin.question') . '</th>
 <th>' . I18n::t('admin.exerciseadmin.answer') . ' (EN)</th>
 <th>' . I18n::t('admin.exerciseadmin.answer') . ' (DE)</th>
 <th>&nbsp;</th>
 </tr>
 </thead>
 <tbody>';
     foreach ((array) Exercise::getMultipleExercises($this->lesson->getId(), 50, 0) as $exercise) {
         $content .= '<tr><input type="hidden" name="exercise_id[]" value="' . $exercise->getId() . '" />
   <td><input type="text" name="question[]" value="' . $exercise->getQuestion() . '" /></td>
   <td><input type="text" name="answer_en[]" value="' . $exercise->getAnswer('en') . '" /></td>
   <td><input type="text" name="answer_de[]" value="' . $exercise->getAnswer('de') . '" /></td>
   </tr>';
     }
     $content .= '</tbody>
 </table>
 <table width="100%">
 <tr><td width="50%" align="left"><button id="exercise-add-btn" class="btn btn-default" type="button">' . I18n::t('button.add') . '</button></td>
 <td width="50%" align="right"><input type="submit" class="btn btn-default" value="' . I18n::t('button.save') . '" /></td></tr>
 </table>
 </form>';
     return $content;
 }
开发者ID:stoeffu,项目名称:hiragana.ch,代码行数:34,代码来源:exerciseadminview.class.php


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