当前位置: 首页>>代码示例>>PHP>>正文


PHP Localization::activeLocale方法代码示例

本文整理汇总了PHP中Localization::activeLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Localization::activeLocale方法的具体用法?PHP Localization::activeLocale怎么用?PHP Localization::activeLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Localization的用法示例。


在下文中一共展示了Localization::activeLocale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: view

 public function view()
 {
     $this->requireAsset('javascript', 'jquery');
     $ml = Section::getList();
     $c = \Page::getCurrentPage();
     $al = Section::getBySectionOfSite($c);
     $languages = [];
     $locale = null;
     if ($al !== null) {
         $locale = $al->getLanguage();
     }
     if (!$locale) {
         $locale = \Localization::activeLocale();
         $al = Section::getByLocale($locale);
     }
     foreach ($ml as $m) {
         $languages[$m->getCollectionID()] = $m->getLanguageText($m->getLocale());
     }
     $this->set('languages', $languages);
     $this->set('languageSections', $ml);
     $this->set('activeLanguage', $al ? $al->getCollectionID() : null);
     $dl = $this->app->make('multilingual/detector');
     $this->set('defaultLocale', $dl->getPreferredSection());
     $this->set('locale', $locale);
     $this->set('cID', $c->getCollectionID());
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:26,代码来源:controller.php

示例2: do_update

	public function do_update($pkgHandle = false) {
		$tp = new TaskPermission();
		if ($tp->canInstallPackages()) { 
			if ($pkgHandle) {
				$tests = Package::testForInstall($pkgHandle, false);
				if (is_array($tests)) {
					$tests = Package::mapError($tests);
					$this->set('error', $tests);
				} else {
					$p = Package::getByHandle($pkgHandle);
					$currentLocale = Localization::activeLocale();
					if ($currentLocale != 'en_US') {
						// Prevent the database records being stored in wrong language
						Localization::changeLocale('en_US');
					}
					try {
						$p->upgradeCoreData();
						if ($currentLocale != 'en_US') {
							Localization::changeLocale($currentLocale);
						}
						$p->upgrade();
						$this->set('message', t('The package has been updated successfully.'));
					} catch(Exception $e) {
						$this->set('error', $e);
					}
				}
			}
		}
		$this->view();
	}
开发者ID:nveid,项目名称:concrete5,代码行数:30,代码来源:update.php

示例3: testAndRunInstall

	protected function testAndRunInstall() {
		if (file_exists(DIR_CONFIG_SITE . '/site_install_user.php')) {
			require(DIR_CONFIG_SITE . '/site_install.php');
			@include(DIR_CONFIG_SITE . '/site_install_user.php');
			if (defined('ACTIVE_LOCALE') && Localization::activeLocale() !== ACTIVE_LOCALE) {
				Localization::changeLocale(ACTIVE_LOCALE);
			}
			$e = Loader::helper('validation/error');
			$e = $this->validateDatabase($e);
			if ($e->has()) {
				$this->set('error', $e);
			} else {
				$this->addHeaderItem(Loader::helper('html')->css('jquery.ui.css'));
				$this->addHeaderItem(Loader::helper('html')->javascript('jquery.ui.js'));
				if (defined('INSTALL_STARTING_POINT') && INSTALL_STARTING_POINT) { 
					$spl = Loader::startingPointPackage(INSTALL_STARTING_POINT);
				} else {
					$spl = Loader::startingPointPackage('standard');
				}
				$this->set('installPackage', $spl->getPackageHandle());
				$this->set('installRoutines', $spl->getInstallRoutines());
				$this->set('successMessage', t('Congratulations. concrete5 has been installed. You have been logged in as <b>%s</b> with the password you chose. If you wish to change this password, you may do so from the users area of the dashboard.', USER_SUPER, $uPassword));
			}
		}
	}
开发者ID:nveid,项目名称:concrete5,代码行数:25,代码来源:install.php

示例4: filterByKeywords

 public function filterByKeywords($kw)
 {
     static $reverseLookup = array();
     $db = Loader::db();
     $locale = Localization::activeLocale();
     if (!array_key_exists($locale, $reverseLookup)) {
         $reverseLookup[$locale] = false;
         if (Localization::activeLocale() != 'en_US' || ENABLE_TRANSLATE_LOCALE_EN_US) {
             $limit = defined('GROUPNAME_REVERSELOOKUP_LIMIT') ? GROUPNAME_REVERSELOOKUP_LIMIT : 100;
             $count = $db->GetOne('select count(*) from Groups');
             if ($count > 0 && $count <= $limit) {
                 $reverseLookup[$locale] = array();
                 $rs = $db->Query('select gID, gName, gDescription from Groups');
                 while ($row = $rs->FetchRow()) {
                     $reverseLookup[$locale][$row['gID']] = array('name' => tc('GroupName', $row['gName']), 'description' => tc('GroupDescription', $row['gDescription']));
                 }
                 $rs->Close();
             }
         }
     }
     if ($reverseLookup[$locale]) {
         $foundIDs = array();
         foreach ($reverseLookup[$locale] as $gID => $gTranslated) {
             if (stripos($gTranslated['name'], $kw) !== false || stripos($gTranslated['description'], $kw) !== false) {
                 $foundIDs[] = $gID;
             }
         }
         if (count($foundIDs)) {
             $this->filter(false, '(Groups.gID in (' . implode(', ', $foundIDs) . '))');
             return;
         }
     }
     $this->filter(false, "(Groups.gName like " . $db->qstr('%' . $kw . '%') . " or Groups.gDescription like " . $db->qstr('%' . $kw . '%') . ")");
 }
开发者ID:Zyqsempai,项目名称:amanet,代码行数:34,代码来源:group.php

示例5: deliverQueryObject

 public function deliverQueryObject()
 {
     $query = parent::deliverQueryObject();
     $u = new User();
     if ($u->isLoggedIn()) {
         $uID = $u->getUserID();
     } else {
         $uID = -1;
     }
     if ($uID != -1) {
         // $query->leftJoin('p', 'UserPageFavorites', 'fav', 'p.cID = fav.cID');
         // $query->addSelect('fav.uID IS NOT NULL as favorite');
         // $query->leftJoin('p', 'UserPageFavorites', 'fav', 'p.pID = fav.pID and fav.uID = '.(int)$u->getUserID());
         $relation = Database::get()->createQueryBuilder();
         $relation->select('mpRelationID')->from('MultilingualPageRelations', 'mppr')->leftJoin('mppr', 'UserPageFavorites', 'fav', 'mppr.CID = fav.cID WHERE fav.uID = :uID')->setParameter('uID', (int) $uID);
         //     // ->
         // andWhere('fav.uID = :uID');
         $query->leftJoin('p', 'MultilingualPageRelations', 'mmpr2', 'p.cID = mmpr2.cID');
         $query->addSelect('mmpr2.mpRelationID');
         // $query->andWhere("mmpr2.mpRelationID in (" . $relation . ")");
         $query->addSelect(' mmpr2.mpRelationID in (' . $relation . ') as favorite');
         $query->andWhere("mmpr2.mpLocale = :loc");
         $query->setParameter('uID', (int) $uID);
         $query->setParameter('loc', \Localization::activeLocale());
         if ($this->onlyFavorites) {
             // Does this slow the query or what
             $query->andWhere('mmpr2.mpRelationID in (' . $relation . ')');
         }
         // var_dump(\Localization::activeLocale());
         // echo $query->getSql();
     }
     return $query;
 }
开发者ID:Bloodb0ne,项目名称:Concrete5_DevRepo,代码行数:33,代码来源:LangFavoritePageList.php

示例6: getMembers

 public function getMembers()
 {
     // get locale
     $locale = \Localization::activeLocale();
     $c = $this->getCollectionObject();
     if (is_object($c)) {
         $al = Section::getBySectionOfSite($c);
         if (is_object($al)) {
             $locale = $al->getLocale();
         }
     }
     // fix for sorting
     if ($locale == 'en_US') {
         $locale = 'en';
     }
     $params = array('limit' => 100, 'member_of' => $this->parentId, 'sort' => '1058', 'l' => $locale);
     // build URL with params
     $uh = \Core::make('helper/url');
     $url = \Config::get('worldskills.api_url', 'https://api.worldskills.org') . '/org/members';
     $url = $uh->buildQuery($url, $params);
     // fetch JSON
     $data = \Core::make("helper/file")->getContents($url);
     $data = json_decode($data, true);
     return $data;
 }
开发者ID:worldskills,项目名称:concrete5-worldskills,代码行数:25,代码来源:controller.php

示例7: __construct

 public function __construct()
 {
     Loader::library('3rdparty/Zend/Locale');
     $countries = Zend_Locale::getTranslationList('territory', Localization::activeLocale(), 2);
     // unset invalid countries
     unset($countries['SU'], $countries['ZZ'], $countries['IM'], $countries['JE'], $countries['VD']);
     asort($countries, SORT_LOCALE_STRING);
     $this->countries = $countries;
 }
开发者ID:ricardomccerqueira,项目名称:rcerqueira.portfolio,代码行数:9,代码来源:countries.php

示例8: getZendLocale

 /** Returns the Zend_Locale instance for the current locale.
  * @return Zend_Locale
  */
 protected function getZendLocale()
 {
     static $zl;
     $locale = Localization::activeLocale();
     if (!isset($zl) || $locale != $zl->toString()) {
         $zl = new Zend_Locale($locale);
     }
     return $zl;
 }
开发者ID:ojalehto,项目名称:concrete5-legacy,代码行数:12,代码来源:number.php

示例9: __construct

 public function __construct()
 {
     Loader::library('3rdparty/Zend/Locale');
     $countries = Zend_Locale::getTranslationList('territory', Localization::activeLocale(), 2);
     unset($countries['FX'], $countries['IM'], $countries['JE'], $countries['NT'], $countries['PU'], $countries['ZZ'], $countries['CS'], $countries['CT'], $countries['DD'], $countries['PC'], $countries['PZ'], $countries['SU'], $countries['VD'], $countries['YD']);
     $countriesFromEvent = Events::fire('on_get_countries_list', $countries);
     if (is_array($countriesFromEvent)) {
         $countries = $countriesFromEvent;
     } else {
         asort($countries, SORT_LOCALE_STRING);
     }
     $this->countries = $countries;
 }
开发者ID:Mihail9575,项目名称:concrete5,代码行数:13,代码来源:countries.php

示例10: getSiteNameForLocale

 /**
  * Get the localized site name.
  *
  * @param string $locale
  *
  * @return string
  */
 protected function getSiteNameForLocale($locale)
 {
     static $names = array();
     if (!isset($names[$locale])) {
         $prevLocale = \Localization::activeLocale();
         if ($prevLocale !== $locale) {
             \Localization::changeLocale($locale);
         }
         $names[$locale] = tc('SiteName', $this->app->make('config')->get('concrete.site'));
         if ($prevLocale !== $locale) {
             \Localization::changeLocale($prevLocale);
         }
     }
     return $names[$locale];
 }
开发者ID:kreativmind,项目名称:concrete5-5.7.0,代码行数:22,代码来源:bulk.php

示例11: translate

 /** 
  * Takes a "field" and grabs all the corresponding disparate fields from $_POST and translates into a timestamp
  * @param string $field The name of the field to translate
  * @param array $arr = null The array containing the value. If null (default) we'll use $_POST
  * @return string|false $dateTime In case of success returns the timestamp (in the format 'Y-m-d H:i:s' or 'Y-m-d'), otherwise returns false ($field value is not in the array) or '' (if $field value is empty).
  * If $field has both date and time, the resulting value will be converted fro user timezone to system timezone.
  * If $field has only date and not time, no timezone conversion will occur. 
  */
 public function translate($field, $arr = null)
 {
     if ($arr == null) {
         $arr = $_POST;
     }
     /* @var $dateHelper DateHelper */
     $dateHelper = Loader::helper('date');
     if (isset($arr[$field . '_dt'])) {
         $value = $arr[$field . '_dt'];
         if (strlen(trim($value)) === 0) {
             return '';
         }
         $format = defined('CUSTOM_DATE_APP_GENERIC_MDY') ? CUSTOM_DATE_APP_GENERIC_MDY : t('n/j/Y');
         $h = is_numeric($arr[$field . '_h']) ? $arr[$field . '_h'] : '00';
         $m = is_numeric($arr[$field . '_m']) ? $arr[$field . '_m'] : '00';
         if (isset($arr[$field . '_a'])) {
             if ($arr[$field . '_a'] === 'AM') {
                 $a = $dateHelper->date('A', mktime(1));
             } else {
                 $a = $dateHelper->date('A', mktime(13));
             }
             $value .= " {$h}:{$m} {$a}";
             $format .= ' h:i A';
         } else {
             $value .= " {$h}:{$m}";
             $format .= ' H:i';
         }
         $d = new Zend_Date();
         $d->setTimezone($dateHelper->getTimezone('user'));
         $d->set($value, $format, Localization::activeLocale());
         return $dateHelper->formatCustom('Y-m-d H:i:s', $d, 'system');
     } elseif (isset($arr[$field])) {
         $value = $arr[$field];
         if (strlen(trim($value)) === 0) {
             return '';
         }
         $format = defined('CUSTOM_DATE_APP_GENERIC_MDY') ? CUSTOM_DATE_APP_GENERIC_MDY : t('n/j/Y');
         $d = new Zend_Date();
         $d->setTimezone($dateHelper->getTimezone('system'));
         $d->set($value, $format, Localization::activeLocale());
         return $dateHelper->formatCustom('Y-m-d', $d, 'system');
     } else {
         return false;
     }
 }
开发者ID:Zyqsempai,项目名称:amanet,代码行数:53,代码来源:date_time.php

示例12: asciify

 /** Takes text and converts it to an ASCII-only string (characters with code between 32 and 127, plus \t, \n and \r).
  * @param string $text The text to be converted.
  * @param string $locale='' The locale for the string. If not specified we consider the current locale.
  * @return string
  */
 public function asciify($text, $locale = '')
 {
     if (!strlen($locale)) {
         $locale = \Localization::activeLocale();
     }
     $language = substr($locale, 0, strcspn($locale, '_'));
     $text = \URLify::downcode($text, $language);
     if (preg_match('/[^\\t\\r\\n\\x20-\\x7e]/', $text)) {
         if (function_exists('iconv')) {
             $t = @iconv(APP_CHARSET, 'US-ASCII//IGNORE//TRANSLIT', $text);
             if (is_string($t)) {
                 $text = $t;
             }
         }
         $text = preg_replace('/[^\\t\\r\\n\\x20-\\x7e]/', '', $text);
     }
     return $text;
 }
开发者ID:meixelsberger,项目名称:concrete5-5.7.0,代码行数:23,代码来源:Text.php

示例13: reset

 public function reset()
 {
     $locale = Localization::activeLocale();
     if ($locale === $this->locale) {
         return;
     }
     $this->locale = $locale;
     $this->stateProvinces['GB'] = $this->stateProvinces['UK'];
     $stateProvincesFromEvent = Events::fire('on_get_states_provinces_list', $this->stateProvinces);
     if (is_array($stateProvincesFromEvent)) {
         $this->stateProvinces = $stateProvincesFromEvent;
     } else {
         foreach (array_keys($this->stateProvinces) as $country) {
             if (!in_array($country, $this->sortedCountries)) {
                 asort($this->stateProvinces[$country]);
             }
         }
     }
 }
开发者ID:Zyqsempai,项目名称:amanet,代码行数:19,代码来源:states_provinces.php

示例14: getMember

 public function getMember()
 {
     // get locale
     $locale = \Localization::activeLocale();
     $c = $this->getCollectionObject();
     if (is_object($c)) {
         $al = Section::getBySectionOfSite($c);
         if (is_object($al)) {
             $locale = $al->getLocale();
         }
     }
     // build URL with params
     $uh = \Core::make('helper/url');
     $url = \Config::get('worldskills.api_url', 'https://api.worldskills.org') . '/org/members/' . $this->memberId;
     $url = $uh->buildQuery($url, array('l' => $locale));
     // fetch JSON
     $data = \Core::make("helper/file")->getContents($url);
     $data = json_decode($data, true);
     return $data;
 }
开发者ID:worldskills,项目名称:concrete5-worldskills,代码行数:20,代码来源:controller.php

示例15: getSkills

 public function getSkills($sort = 'name_asc')
 {
     // get locale
     $locale = \Localization::activeLocale();
     $c = $this->getCollectionObject();
     if (is_object($c)) {
         $al = Section::getBySectionOfSite($c);
         if (is_object($al)) {
             $locale = $al->getLocale();
         }
     }
     // fix for sorting
     if ($locale == 'en_US') {
         $locale = 'en';
     }
     // defaults
     $params = array('limit' => 100, 'sort' => $sort, 'l' => $locale);
     // build URL with params
     $url = \Config::get('worldskills.api_url', 'https://api.worldskills.org') . '/events/' . $this->eventId . '/skills';
     $url .= '?';
     $url .= http_build_query($params);
     // block settings
     if ($this->sectorId) {
         $url .= '&';
         $url .= http_build_query(array('sector' => $this->sectorId));
     }
     if ($this->types) {
         $skillTypes = explode(',', $this->types);
         foreach ($skillTypes as $skillType) {
             $url .= '&';
             $url .= http_build_query(array('type' => $skillType));
         }
     }
     // fetch JSON
     $data = \Core::make("helper/file")->getContents($url);
     $data = json_decode($data, true);
     return $data;
 }
开发者ID:worldskills,项目名称:concrete5-worldskills,代码行数:38,代码来源:controller.php


注:本文中的Localization::activeLocale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。