本文整理匯總了PHP中CAppUI::lang方法的典型用法代碼示例。如果您正苦於以下問題:PHP CAppUI::lang方法的具體用法?PHP CAppUI::lang怎麽用?PHP CAppUI::lang使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CAppUI
的用法示例。
在下文中一共展示了CAppUI::lang方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: loadLocales
/**
* Load locales from cache or build the cache
*
* @return void
*/
public static function loadLocales()
{
$lang = CAppUI::pref("LOCALE", "fr");
self::$lang = $lang;
$shared_name = "locales-{$lang}";
$locales_prefixes = SHM::get("{$shared_name}-" . self::LOCALES_PREFIX);
// Load from shared memory if possible
if ($locales_prefixes) {
return;
}
$mutex = new CMbFileMutex("locales-build");
$mutex->acquire(5);
$locales_prefixes = SHM::get("{$shared_name}-" . self::LOCALES_PREFIX);
// Load from shared memory if possible
if ($locales_prefixes) {
$mutex->release();
return;
}
$locales = array();
foreach (self::getLocaleFilesPaths($lang) as $_path) {
include_once $_path;
}
$locales = CMbString::filterEmpty($locales);
foreach ($locales as &$_locale) {
$_locale = CMbString::unslash($_locale);
}
unset($_locale);
// Load overwritten locales if the table exists
$overwrite = new CTranslationOverwrite();
if ($overwrite->isInstalled()) {
$locales = $overwrite->transformLocales($locales, $lang);
}
// Prefix = everything before "." and "-"
$by_prefix = array();
$hashes = array();
foreach ($locales as $_key => $_value) {
/** @var string $_prefix */
/** @var string $_rest */
/** @var string $_prefix_raw */
list($_prefix, $_rest, $_prefix_raw) = self::splitLocale($_key);
if (!isset($by_prefix[$_prefix])) {
$hashes[$_prefix] = $_prefix_raw;
$by_prefix[$_prefix] = array();
}
$by_prefix[$_prefix][$_rest] = $_value;
}
foreach ($by_prefix as $_prefix => $_locales) {
self::$locales[$_prefix] = $_locales;
self::$locales_loaded[$_prefix] = true;
SHM::put("{$shared_name}-{$_prefix}", $_locales);
}
SHM::put("{$shared_name}-" . self::LOCALES_PREFIX, $hashes);
$mutex->release();
}