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


PHP I18n::instance方法代码示例

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


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

示例1: getInstance

 /**
  * get already existing instance, make new instance or throw an exception
  * @return I18n
  */
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new I18n();
     }
     return self::$instance;
 }
开发者ID:NEOatNHNG,项目名称:cacert-testmgr,代码行数:11,代码来源:I18n.php

示例2: init

 /**
  * Initializing I18n
  *
  * @param string $dir Plugins directory
  */
 public static function init($locale)
 {
     if (!isset(self::$instance)) {
         self::$instance = new I18n($locale);
     }
     return self::$instance;
 }
开发者ID:rowena-altastratus,项目名称:altastratus,代码行数:12,代码来源:I18n.php

示例3: getInstance

 /**
  * Retorna a instância da classes (padrão singleton)
  * @return	object				retorna a instância de I18n
  */
 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self(Config::get('default_lang'));
     }
     return self::$instance;
 }
开发者ID:nylmarcos,项目名称:estagio,代码行数:11,代码来源:I18n.php

示例4: gallery_ready

 /**
  * Initialization.
  */
 static function gallery_ready()
 {
     user::load_user();
     $locale = user::active()->locale;
     if (!empty($locale)) {
         // TODO(andy_st): Check session data as well.
         I18n::instance()->locale($locale);
     }
 }
开发者ID:eo04837,项目名称:gallery3,代码行数:12,代码来源:user_event.php

示例5: setup

 public function setup()
 {
     $config = array('root_locale' => 'en', 'default_locale' => 'te_ST', 'locale_dir' => VARPATH . 'locale/');
     $this->i18n = I18n::instance($config);
     ORM::factory("incoming_translation")->where("locale", "te_ST")->delete_all();
     $messages_te_ST = array(array('Hello world', 'Hallo Welt'), array(array('one' => 'One item has been added', 'other' => '%count elements have been added'), array('one' => 'Ein Element wurde hinzugefuegt.', 'other' => '%count Elemente wurden hinzugefuegt.')), array('Hello %name, how are you today?', 'Hallo %name, wie geht es Dir heute?'));
     foreach ($messages_te_ST as $data) {
         list($message, $translation) = $data;
         $entry = ORM::factory("incoming_translation");
         $entry->key = I18n::get_message_key($message);
         $entry->message = serialize($message);
         $entry->translation = serialize($translation);
         $entry->locale = 'te_ST';
         $entry->revision = null;
         $entry->save();
     }
 }
开发者ID:xafr,项目名称:gallery3,代码行数:17,代码来源:I18n_Test.php

示例6: set_request_locale

 static function set_request_locale()
 {
     // 1. Check the session specific preference (cookie)
     $locale = user::cookie_locale();
     // 2. Check the user's preference
     if (!$locale) {
         $locale = user::active()->locale;
     }
     // 3. Check the browser's / OS' preference
     if (!$locale) {
         $locale = locales::locale_from_http_request();
     }
     // If we have any preference, override the site's default locale
     if ($locale) {
         I18n::instance()->locale($locale);
     }
 }
开发者ID:Okat,项目名称:gallery3,代码行数:17,代码来源:user_event.php

示例7: initialize

 /**
  * Initializes the core.
  * @return bool
  */
 public static function initialize()
 {
     if (self::$_init) {
         // Do not allow to execution twice
         return false;
     }
     self::$_init = true;
     // Determine if we are running in a Windows environment
     self::$is_win = DIRECTORY_SEPARATOR === '\\';
     // Load the logger
     self::$log = Log::instance();
     // Load the default configuration files
     self::$config = Config::instance()->attach(new Config_File());
     // Load the i18n class
     self::$i18n = I18n::instance();
     // Enable debug log
     if (self::$log_debug) {
         self::$log->attach(new Log_File(APPPATH . 'data/log/debug'), array('EXIDO_DEBUG_LOG'));
         self::$log->add('EXIDO_DEBUG_LOG', 'Initialize framework');
     }
     // Enable error log
     if (self::$log_error) {
         self::$log->attach(new Log_File(APPPATH . 'data/log/error'), array('EXIDO_ERROR_LOG'));
     }
     // Determine if we are running in a command line environment
     self::$is_cli = PHP_SAPI === 'cli';
     // Check if we have an Ajax request
     self::$is_xml = Input::instance()->isXmlRequest();
     // Load helpers
     Helper::load('lang', 'uri');
     // Check if we can use gZIP compression
     self::$use_gzip = strstr(Input::instance()->server('HTTP_ACCEPT_ENCODING'), "gzip") !== false and extension_loaded("zlib");
     // Start output buffering
     ob_start(array(__CLASS__, 'outputBuffer'));
     // Save buffering level
     self::$_buffer_level = ob_get_level();
     Event::add('system.routing', array('Router', 'getUri'));
     Event::add('system.routing', array('Router', 'initialize'));
     Event::add('system.execute', array(__CLASS__, 'instance'));
     Event::add('system.shutdown', array(__CLASS__, 'shutdown'));
     return true;
 }
开发者ID:esironal,项目名称:exidoengine,代码行数:46,代码来源:exido.php

示例8: t2

/**
 * Translates a localizable message with plural forms.
 * @param $singular String The message to be translated. E.g. "There is one album."
 * @param $plural String The plural message to be translated. E.g.
 *        "There are %count albums."
 * @param $count Number The number which is inserted for the %count placeholder and
 *        which is used to select the proper plural form ($singular or $plural).
 * @param $options array (optional) Options array for key value pairs which are used
 *        for pluralization and interpolation. Special key: "locale" to override the
 *        currently configured locale.
 * @return String The translated message string.
 */
function t2($singular, $plural, $count, $options = array())
{
    return I18n::instance()->translate(array("one" => $singular, "other" => $plural), array_merge($options, array("count" => $count)));
}
开发者ID:xafr,项目名称:gallery3,代码行数:16,代码来源:I18n.php

示例9: l10n_form

 public static function l10n_form()
 {
     if (Input::instance()->get("show_all_l10n_messages")) {
         $calls = array();
         foreach (Database::instance()->select("key", "message")->from("incoming_translations")->where(array("locale" => 'root'))->get()->as_array() as $row) {
             $calls[$row->key] = array(unserialize($row->message), array());
         }
     } else {
         $calls = I18n::instance()->call_log();
     }
     $locale = I18n::instance()->locale();
     if ($calls) {
         $translations = array();
         foreach (Database::instance()->select("key", "translation")->from("incoming_translations")->where(array("locale" => $locale))->get()->as_array() as $row) {
             $translations[$row->key] = unserialize($row->translation);
         }
         // Override incoming with outgoing...
         foreach (Database::instance()->select("key", "translation")->from("outgoing_translations")->where(array("locale" => $locale))->get()->as_array() as $row) {
             $translations[$row->key] = unserialize($row->translation);
         }
         $string_list = array();
         $cache = array();
         foreach ($calls as $key => $call) {
             list($message, $options) = $call;
             // Ensure that the message is in the DB
             l10n_scanner::process_message($message, $cache);
             // Note: Not interpolating placeholders for the actual translation input field.
             // TODO: Might show a preview w/ interpolations (using $options)
             $translation = isset($translations[$key]) ? $translations[$key] : '';
             $string_list[] = array('source' => $message, 'key' => $key, 'translation' => $translation);
         }
         $v = new View('l10n_client.html');
         $v->string_list = $string_list;
         $v->l10n_search_form = self::_l10n_client_search_form();
         $v->plural_forms = l10n_client::plural_forms($locale);
         return $v;
     }
     return '';
 }
开发者ID:ChrisRut,项目名称:gallery3,代码行数:39,代码来源:l10n_client.php

示例10: is_rtl

 static function is_rtl($locale = null)
 {
     $locale or $locale = I18n::instance()->locale();
     list($language, $territory) = explode('_', $locale . "_");
     return in_array($language, array("he", "fa", "ar"));
 }
开发者ID:roypa,项目名称:bbg,代码行数:6,代码来源:locales.php

示例11: display_name

 static function display_name($locale = null)
 {
     if (empty(self::$locales)) {
         self::_init_language_data();
     }
     $locale or $locale = I18n::instance()->locale();
     return self::$locales["{$locale}"];
 }
开发者ID:xafr,项目名称:gallery3,代码行数:8,代码来源:locale.php

示例12: l10n_form

 public static function l10n_form()
 {
     $calls = I18n::instance()->call_log();
     if ($calls) {
         $string_list = array();
         foreach ($calls as $call) {
             list($message, $options) = $call;
             // Note: Don't interpolate placeholders for the actual translation input field.
             // TODO: Use $options to generate a preview.
             if (is_array($message)) {
                 // TODO: Handle plural forms.
                 //   Translate each message. If it has a plural form, get
                 //   the current locale's plural rules and all plural translations.
                 continue;
             }
             $source = $message;
             $translation = '';
             $options_for_raw_translation = array();
             if (isset($options['count'])) {
                 $options_for_raw_translation['count'] = $options['count'];
             }
             if (I18n::instance()->has_translation($message, $options_for_raw_translation)) {
                 $translation = I18n::instance()->translate($message, $options_for_raw_translation);
             }
             $string_list[] = array('source' => $source, 'translation' => $translation);
         }
         $v = new View('l10n_client.html');
         $v->string_list = $string_list;
         $v->l10n_form = self::_l10n_client_form();
         $v->l10n_search_form = self::_l10n_client_search_form();
         return $v;
     }
     return '';
 }
开发者ID:xafr,项目名称:gallery3,代码行数:34,代码来源:l10n_client.php


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