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


PHP Locales::init方法代码示例

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


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

示例1: basic

 /** Basic initialization - preload settings and locales
  * @return void
  */
 public static function basic()
 {
     Loader::init();
     Status::init();
     Settings::init();
     Locales::init();
     Router::update_rewrite();
 }
开发者ID:just-paja,项目名称:fudjan,代码行数:11,代码来源:init.php

示例2: init

 /** Initializes the bot.
  * Initializes the bot, by reading arguments, parsing configs sections, initializes server instances, and many other things.
  * 
  * \param $CLIArguments list of arguments provided to the launcher, or generated ones (for further integration into other systems).
  * \return TRUE in case of success, FALSE otherwise.
  */
 public function init($CLIArguments)
 {
     //Start Cpu Monitoring
     $this->cpuRequestStart();
     //Setting default values for class attributes
     Leelabot::$instance =& $this;
     $this->_configDirectory = 'conf';
     Leelabot::$verbose = FALSE;
     $this->servers = array();
     $this->system = php_uname('a');
     $this->_showIPS = FALSE;
     $this->_iterations = 0;
     $this->_IPSHistory = array_fill(0, 10, 0);
     //Parsing CLI arguments
     $logContent = NULL;
     $CLIArguments = Leelabot::parseArgs($CLIArguments);
     //Checking CLI argument for root modification, and modification in case
     if ($rootParam = array_intersect(array('r', 'root'), array_keys($CLIArguments))) {
         chdir($CLIArguments[$rootParam[0]]);
     }
     //Setting root
     $this->root = getcwd();
     //Opening default log file (can be modified after, if requested)
     Leelabot::$_logFile = fopen('leelabot.log', 'a+');
     fseek(Leelabot::$_logFile, 0, SEEK_END);
     $initPos = ftell(Leelabot::$_logFile);
     //Loading Intl class (if it is not loadable, load a dummy substitute)
     $this->intl = new Intl(Leelabot::DEFAULT_LOCALE);
     if (!$this->intl->init) {
         $this->intl = new Intl();
         //Load class without a locale defined
         Leelabot::message('Can\'t load Intl class with default locale ($0).', array(Leelabot::DEFAULT_LOCALE), E_ERROR);
         exit;
     }
     Leelabot::message('Leelabot version $0 starting...', array(Leelabot::VERSION), E_NOTICE, TRUE);
     //Loading plugin manager class
     $this->plugins = new PluginManager($this);
     Plugins::setPluginManager($this->plugins);
     //Pre-parsing CLI arguments (these arguments are relative to config loading and files location)
     $this->processCLIPreparsingArguments($CLIArguments);
     //Loading config
     if (!$this->loadConfig()) {
         Leelabot::message("Startup aborted : Can't parse startup config.", array(), E_ERROR);
         exit;
     }
     //Checking if the number of servers defined in the config is not greater than the limit defined in the CLI
     if ($this->maxServers > 0 && count($this->config['Server']) > $this->maxServers) {
         Leelabot::message("Number of set servers in the config is greater than the limit (\$0).", array($this->maxServers), E_ERROR);
         exit;
     }
     //Processing loaded config (for main parameters)
     if (isset($this->config['Main'])) {
         $logContent = '';
         //Setting the locale in accordance with the configuration (if set)
         foreach ($this->config['Main'] as $name => $value) {
             switch ($name) {
                 case 'Locale':
                     Leelabot::message('Changed locale by configuration : $0', array($this->config['Main']['Locale']));
                     if (!$this->intl->setLocale($this->config['Main']['Locale'])) {
                         Leelabot::message('Cannot change locale to "$0"', array($this->config['Main']['Locale']), E_WARNING);
                     } else {
                         Leelabot::message('Locale successfully changed to "$0".', array($this->config['Main']['Locale']));
                     }
                     break;
                 case 'UseLog':
                     if (Leelabot::parseBool($value) == FALSE) {
                         Leelabot::message('Disabling log (by Config).');
                         //Save log content for later parameters (like when using --nolog -log file.log)
                         if (Leelabot::$_logFile) {
                             $logContent = '';
                             fseek(Leelabot::$_logFile, $initPos);
                             while (!feof(Leelabot::$_logFile)) {
                                 $logContent .= fgets(Leelabot::$_logFile);
                             }
                             //If the file was empty before logging into it, delete it
                             if ($initPos == 0) {
                                 $logFileInfo = stream_get_meta_data(Leelabot::$_logFile);
                                 fclose(Leelabot::$_logFile);
                                 unlink($logFileInfo['uri']);
                             } else {
                                 fclose(Leelabot::$_logFile);
                             }
                             Leelabot::$_logFile = FALSE;
                         }
                     }
                     break;
                 case 'BotName':
                     $this->botName = $value;
                     break;
                 case 'ShowIPS':
                     $this->_showIPS = Leelabot::parseBool($value);
                     break;
                 case 'LogFile':
                     Leelabot::message('Changing log file to $0 (by Config)', array($value));
//.........这里部分代码省略.........
开发者ID:Geolim4,项目名称:Leelabot,代码行数:101,代码来源:leelabot.class.php


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