本文整理匯總了PHP中DevblocksPlatform::getLocale方法的典型用法代碼示例。如果您正苦於以下問題:PHP DevblocksPlatform::getLocale方法的具體用法?PHP DevblocksPlatform::getLocale怎麽用?PHP DevblocksPlatform::getLocale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DevblocksPlatform
的用法示例。
在下文中一共展示了DevblocksPlatform::getLocale方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getTranslationService
/**
* @return _DevblocksTranslationManager
*/
static function getTranslationService()
{
static $languages = array();
$locale = DevblocksPlatform::getLocale();
// Registry
if (isset($languages[$locale])) {
return $languages[$locale];
}
$cache = self::getCacheService();
if (null === ($map = $cache->load(self::CACHE_TAG_TRANSLATIONS . '_' . $locale))) {
/* @var $cache _DevblocksCacheManager */
$map = array();
$map_en = DAO_Translation::getMapByLang('en_US');
if (0 != strcasecmp('en_US', $locale)) {
$map_loc = DAO_Translation::getMapByLang($locale);
}
// Loop through the English string objects
if (is_array($map_en)) {
foreach ($map_en as $string_id => $obj_string_en) {
$string = '';
// If we have a locale to check
if (isset($map_loc) && is_array($map_loc)) {
@($obj_string_loc = $map_loc[$string_id]);
@($string = !empty($obj_string_loc->string_override) ? $obj_string_loc->string_override : $obj_string_loc->string_default);
}
// If we didn't hit, load the English default
if (empty($string)) {
@($string = !empty($obj_string_en->string_override) ? $obj_string_en->string_override : $obj_string_en->string_default);
}
// If we found any match
if (!empty($string)) {
$map[$string_id] = $string;
}
}
}
unset($obj_string_en);
unset($obj_string_loc);
unset($map_en);
unset($map_loc);
// Cache with tag (tag allows easy clean for multiple langs at once)
$cache->save($map, self::CACHE_TAG_TRANSLATIONS . '_' . $locale);
}
$translate = _DevblocksTranslationManager::getInstance();
$translate->addLocale($locale, $map);
$translate->setLocale($locale);
$languages[$locale] = $translate;
return $translate;
}