本文整理汇总了PHP中I18n::getLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP I18n::getLocale方法的具体用法?PHP I18n::getLocale怎么用?PHP I18n::getLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类I18n
的用法示例。
在下文中一共展示了I18n::getLocale方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
/**
* Initialize all activated plugin by including is index.php file.
* Also load all language files for plugins available in plugins directory.
*/
static function init()
{
$dir = PLUGINS_ROOT . DS;
if ($handle = opendir($dir)) {
while (false !== ($plugin_id = readdir($handle))) {
$file = $dir . $plugin_id . DS . 'i18n' . DS . I18n::getLocale() . '-message.php';
$default_file = PLUGINS_ROOT . DS . $plugin_id . DS . 'i18n' . DS . DEFAULT_LOCALE . '-message.php';
if (file_exists($file)) {
$array = (include $file);
I18n::add($array);
}
if (file_exists($default_file)) {
$array = (include $default_file);
I18n::addDefault($array);
}
}
}
self::$plugins = unserialize(Setting::get('plugins'));
foreach (self::$plugins as $plugin_id => $tmp) {
$file = PLUGINS_ROOT . DS . $plugin_id . DS . 'index.php';
if (file_exists($file)) {
include $file;
}
}
}
示例2: __
/**
* This function is as flexible as possible, you can choose your own pattern for variables in
* the string.
*
* Examples of variables are: ':var_name', '#var_name', '{varname}',
* '%varname', '%varname%', 'VARNAME', etc...
*
* <code>
* return = array('hello world!' => 'bonjour le monde!',
* 'user ":user" is logged in' => 'l\'utilisateur ":user" est connecté',
* 'Posted by %user% on %month% %day% %year% at %time%' => 'Publié par %user% le %day% %month% %year% à %time%'
* );
*
* __('hello world!'); // bonjour le monde!
* __('user ":user" is logged in', array(':user' => $user)); // l'utilisateur "demo" est connecté
* __('Posted by %user% on %month% %day% %year% at %time%', array(
* '%user%' => $user,
* '%month%' => __($month),
* '%day%' => $day,
* '%year%' => $year,
* '%time%' => $time)); // Publié par demo le 3 janvier 2006 à 19:30
* </code>
*/
function __($string, $args = null)
{
if (I18n::getLocale() != DEFAULT_LOCALE) {
$string = I18n::getText($string);
}
if ($args === null) {
return $string;
}
return strtr($string, $args);
}
示例3: getInstance
/**
* Returns dateFormat instance
*
* @return f_date_Format Return singleton instance of f_date_Format
*/
public static function getInstance($region = null)
{
if ($region === null) {
$region = I18n::getLocale();
}
if (!isset(self::$_instances[$region])) {
self::$_instances[$region] = new self($region);
}
return self::$_instances[$region];
}
示例4: init
/**
* Initialize all activated plugin by including is index.php file
*/
static function init()
{
self::$plugins = unserialize(Setting::get('plugins'));
foreach (self::$plugins as $plugin_id => $tmp) {
$file = CORE_ROOT . '/plugins/' . $plugin_id . '/index.php';
if (file_exists($file)) {
include $file;
}
$file = CORE_ROOT . '/plugins/' . $plugin_id . '/i18n/' . I18n::getLocale() . '-message.php';
if (file_exists($file)) {
$array = (include $file);
I18n::add($array);
}
}
}
示例5: _filemanager_lang
private function _filemanager_lang()
{
$trans = array('ca', 'cs', 'da', 'de', 'en', 'es', 'fi', 'fr', 'he', 'hu', 'it', 'ja', 'nl', 'pl', 'pt', 'ru', 'sv', 'tr', 'vn', 'cn');
$user_lang = I18n::getLocale();
$lang = in_array($user_lang, $trans) ? $user_lang : 'en';
if ($lang == 'cn') {
$lang = 'zh-cn';
}
return $lang;
}
示例6: _addErrorMessage
/**
* Return code and message from a given error code
*
* @param integer $code
* @return array Array containing the error code and the error text
*/
private function _addErrorMessage($code)
{
$codes = array(UPLOAD_ERR_OK => 'There is no error, the file uploaded with success', UPLOAD_ERR_INI_SIZE => 'The uploaded file exceeds the upload_max_filesize directive in php.ini', UPLOAD_ERR_FORM_SIZE => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', UPLOAD_ERR_PARTIAL => 'The uploaded file was only partially uploaded', UPLOAD_ERR_NO_FILE => 'No file was uploaded', UPLOAD_ERR_NO_TMP_DIR => 'Missing a temporary folder', UPLOAD_ERR_CANT_WRITE => 'Failed to write file to disk', UPLOAD_ERR_EXTENSION => 'A PHP extension stopped the file upload', self::UPLOAD_ERR_MAX_SIZE => 'The file uploaded exceeds the maximum file size defined in the configuration', self::UPLOAD_ERR_FILE_EXTENSION => 'The extension of the file uploaded is blacklisted or not whitelisted', self::UPLOAD_ERR_FILE_TYPE => 'The type of the file uploaded is blacklisted or not whitelisted', self::UPLOAD_ERR_FILE_NOT_IMAGE => 'The file uploaded is not an image', self::UPLOAD_ERR_MOVE_FAILED => 'The uploaded filename could not be moved from temporary storage to the path specified', self::UPLOAD_ERR_OVERWRITE => 'The uploaded filename could not be saved because a file with that name already exists');
$this->errors[$code] = I18n::t(FW_DIR . DS . 'lib' . DS . 'locales' . DS . 'upload.' . I18n::getLocale() . '.xml', $codes[$code], array(), 'en_US');
}