本文整理汇总了PHP中Resources::IsLocaleAvailable方法的典型用法代码示例。如果您正苦于以下问题:PHP Resources::IsLocaleAvailable方法的具体用法?PHP Resources::IsLocaleAvailable怎么用?PHP Resources::IsLocaleAvailable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resources
的用法示例。
在下文中一共展示了Resources::IsLocaleAvailable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getImageNameFromParam
public static function getImageNameFromParam($pImage, $pDepartmentKey = null, $pLang = null, $pImagePostfix = null, $hasOnline = null)
{
if (!preg_match('/\\.(gif|jpg|png)$/i', $pImage)) {
$image = $pImage . '.gif';
} else {
$image = $pImage;
}
if (empty($pLang) || !Resources::IsLocaleAvailable($pLang)) {
$lang = Resources::getCurrentLocale();
} else {
$lang = $pLang;
}
if (empty($pImagePostfix)) {
if (empty($hasOnline)) {
$image_postfix = Operator::getInstance()->hasOnlineOperators($pDepartmentKey, $lang) ? 'on' : 'off';
} else {
$image_postfix = $hasOnline ? 'on' : 'off';
}
} else {
$image_postfix = $pImagePostfix;
}
$image = preg_replace('/\\.(gif|jpg|png)/i', '_' . $image_postfix . '.\\1', $image);
return "/themes/.buttons/{$lang}/{$image}";
}
示例2: getCurrentLocale
public static function getCurrentLocale()
{
$lang = DEFAULT_LOCALE;
// check get
if (!empty($_REQUEST['lang']) && Resources::IsLocaleAvailable($_REQUEST['lang'])) {
$lang = $_REQUEST['lang'];
$_SESSION['lang'] = $_REQUEST['lang'];
setcookie('WEBIM_LOCALE', $_REQUEST['lang'], time() + 60 * 60 * 24 * 1000, WEBIM_ROOT . "/");
} elseif (isset($_SESSION['lang']) && Resources::IsLocaleAvailable($_SESSION['lang'])) {
// check session
$lang = $_SESSION['lang'];
} elseif (isset($_COOKIE['WEBIM_LOCALE']) && Resources::IsLocaleAvailable($_COOKIE['WEBIM_LOCALE'])) {
// check cookie
$lang = $_COOKIE['WEBIM_LOCALE'];
} elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
// check accept language
$requested_langs = explode(",", $_SERVER['HTTP_ACCEPT_LANGUAGE']);
foreach ($requested_langs as $requested_lang) {
if (strlen($requested_lang) > 2) {
$requested_lang = substr($requested_lang, 0, 2);
}
if (Resources::IsLocaleAvailable($requested_lang)) {
$lang = $requested_lang;
break;
}
}
} elseif (Resources::IsLocaleAvailable(DEFAULT_LOCALE)) {
// check the default locale
$lang = DEFAULT_LOCALE;
} else {
// can't find lang
$lang = 'ru';
}
return $lang;
}