本文整理汇总了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();
}
示例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));
//.........这里部分代码省略.........