本文整理汇总了PHP中Seitenbau\Registry::getLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::getLocale方法的具体用法?PHP Registry::getLocale怎么用?PHP Registry::getLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Seitenbau\Registry
的用法示例。
在下文中一共展示了Registry::getLocale方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _
/**
* @param string $key
* @param Seitenbau\Locale $locale
* @return string
*/
protected static function _($key, $locale = null)
{
if (is_null($locale)) {
$locale = Registry::getLocale('Zend_Translate');
}
return Registry::get('Zend_Translate')->_($key, $locale);
}
示例2: setCurrentLang
/**
* @param string $lang
* @return void
*/
protected function setCurrentLang($lang)
{
if (empty($lang) || !SbLocale::isLocale($lang, true)) {
return false;
}
$locale = new SbLocale($lang);
if (!$locale instanceof SbLocale) {
return false;
}
Registry::getLocale()->setLocale($locale);
$translate = Registry::get('Zend_Translate');
if ($translate instanceof \Zend_Translate) {
$translate->setLocale($locale);
}
return true;
}
示例3: setLocaleShouldSetLocale
/**
* @test
* @group library
*/
public function setLocaleShouldSetLocale()
{
$this->assertInstanceOf('Zend_Locale', Registry::getLocale());
}
示例4: getLocale
/**
* Gibt die \Seitenbau\Locale zurueck
* @return \Seitenbau\Locale
*/
protected static function getLocale($locale = null)
{
if ($locale instanceof SbLocale) {
return $locale;
}
if (SbLocale::isLocale($locale)) {
return new SbLocale($locale);
}
$locale = Registry::getLocale();
if (!is_null($locale)) {
return $locale;
}
return self::getDefaultLocale();
}
示例5: _
protected function _($key, $locale = null)
{
if (is_null($locale)) {
$locale = Registry::getLocale('Zend_Translate');
}
return $this->getTranslator()->_($key, $locale);
}
示例6: _initTranslator
protected function _initTranslator()
{
$this->bootstrap('locale');
$locale = $this->getResource('locale');
$translationConfig = Registry::getConfig()->translation;
if (isset($translationConfig->route)) {
$route = $translationConfig->route->toArray();
} else {
$route = array();
}
$defaultLocale = Registry::getLocale();
foreach (array_keys($route) as $routeLangFrom) {
if (strtolower($routeLangFrom) == strtolower($defaultLocale->toString()) || strtolower($routeLangFrom) == strtolower($defaultLocale->getLanguage())) {
unset($route[$routeLangFrom]);
}
}
$translate = new \Zend_Translate(array('adapter' => 'Zend_Translate_Adapter_Array', 'content' => $translationConfig->directory, 'scan' => Zend_Translate::LOCALE_DIRECTORY, 'locale' => $locale, 'disableNotices' => APPLICATION_ENV === 'testing' ? false : true, 'route' => $route));
Registry::set('Zend_Translate', $translate);
}
示例7: getInterfaceLocaleCode
/**
* @return string
*/
protected function getInterfaceLocaleCode()
{
return (string) Registry::getLocale();
}