本文整理汇总了PHP中Zend_Locale::getDefault方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Locale::getDefault方法的具体用法?PHP Zend_Locale::getDefault怎么用?PHP Zend_Locale::getDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Locale
的用法示例。
在下文中一共展示了Zend_Locale::getDefault方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testgetDefault
/**
* test getDefault
* expected true
*/
public function testgetDefault()
{
$value = new Zend_Locale();
$default = $value->getDefault();
$this->assertTrue(is_array($default), 'No Default Locale found');
$default = $value->getDefault(Zend_Locale::BROWSER);
$this->assertTrue(is_array($default), 'No Default Locale found');
$default = $value->getDefault(Zend_Locale::ENVIRONMENT);
$this->assertTrue(is_array($default), 'No Default Locale found');
$default = $value->getDefault(Zend_Locale::FRAMEWORK);
$this->assertTrue(is_array($default), 'No Default Locale found');
}
示例2: __construct
public function __construct($locale = null)
{
if ($locale === null) {
$locale = key(Zend_Locale::getDefault());
} elseif (empty($locale)) {
$locale = 'en_US';
}
$this->locale = $locale;
}
示例3: localeShort
public function localeShort()
{
$translator = $this->view->getHelper('translate')->getTranslator();
$locale = $translator->getLocale();
if (!$translator->isAvailable($locale)) {
$defaults = Zend_Locale::getDefault();
arsort($defaults);
$locale = key($defaults);
}
$locale = new Zend_Locale($locale);
return $locale->getLanguage();
}
示例4: getRouter
/**
* Retrieve router object
*
* @return Zend_Controller_Router_Rewrite
*/
public function getRouter()
{
$routesIni = $this->_getRoutesConfig();
$this->setOptions($routesIni->toArray());
$options = $this->getOptions();
if ($this->_localeIsEnabled()) {
$bootstrap = $this->getBootstrap();
if (!$this->_locale) {
$bootstrap->bootstrap('Locale');
$this->_locale = $bootstrap->getContainer()->locale;
}
$defaultLocale = array_keys($this->_locale->getDefault());
$defaultLocale = $defaultLocale[0];
$locales = $this->_getPossibleLocales();
$routes = $options['routes'];
$localizedRoutes = Garp_I18n::getLocalizedRoutes($routes, $locales);
$options['routes'] = array_merge($routes, $localizedRoutes);
$this->setOptions($options);
}
$router = parent::getRouter();
$router->addDefaultRoutes();
return $router;
}
示例5: Translate
public function Translate($text)
{
$translated = $text;
try {
$locale = new Zend_Locale(Zend_Locale::BROWSER);
$translate = Zend_Registry::get('translate');
if (!$translate->isAvailable($locale)) {
$translate->setLocale(Zend_Locale::getDefault());
}
$translated = $translate->_($text);
} catch (Exception $e) {
Zend_Registry::get('logger')->err($e->getMessage());
}
return $translated;
}
示例6: getTranslate
/**
* Retrieve translate object
*
* @return Zend_Translate
*/
public function getTranslate()
{
$options = $this->getOptions();
if (!isset($options['data'])) {
throw new Zend_Application_Resource_Exception('No translation source data provided in the ini file for: ' . get_class($this->getBootstrap()) . '.');
}
foreach (Zend_Locale::getDefault() as $default => $value) {
break;
}
$adapter = isset($options['adapter']) ? $options['adapter'] : Zend_Translate::AN_ARRAY;
$locale = isset($options['locale']) ? $options['locale'] : $default;
$translateOptions = isset($options['options']) ? $options['options'] : array();
$key = isset($options['registry_key']) && !is_numeric($options['registry_key']) ? $options['registry_key'] : self::DEFAULT_REGISTRY_KEY;
// If no translate object was set in the registry we create it.
if (!Zend_Registry::isRegistered($key)) {
$this->_createTranslation($adapter, $options['data'], $locale, $translateOptions);
// if there is, we should add a translation source to the existing translate object
} elseif (Zend_Registry::isRegistered($key)) {
$this->_translate = Zend_Registry::get($key);
$this->_addTranslation($options['data'], $locale, $translateOptions);
}
Zend_Registry::set($key, $this->_translate);
return $this->_translate;
}
示例7: testgetDefault
/**
* test getDefault
* expected true
*/
public function testgetDefault()
{
Zend_Locale::setDefault('de');
$value = new Zend_Locale();
$default = $value->getDefault();
$this->assertTrue(array_key_exists('de', $default));
$default = $value->getDefault();
$this->assertTrue(is_array($default));
$default = $value->getDefault(Zend_Locale::BROWSER);
$this->assertTrue(is_array($default));
$default = $value->getDefault(Zend_Locale::ENVIRONMENT);
$this->assertTrue(is_array($default));
$default = $value->getDefault(Zend_Locale::FRAMEWORK);
$this->assertTrue(is_array($default));
}
示例8: isLocale
/**
* Checks if a locale identifier is a real locale or not
* Examples:
* "en_XX" refers to "en", which returns true
* "XX_yy" refers to "root", which returns false
*
* @param string|Zend_Locale $locale Locale to check for
* @param boolean $create If true, create a default locale, if $locale is empty
* @return false|string false if given locale is not a locale, else the locale identifier is returned
*/
public static function isLocale($locale, $create = false)
{
if (empty($locale) and ($create === true)) {
$locale = new Zend_Locale();
}
if ($locale instanceof Zend_Locale) {
return $locale->toString();
}
if (!is_string($locale)) {
return false;
}
if (empty(self::$_auto)) {
$temp = new Zend_Locale($locale);
self::$_auto = $temp->getDefault(null, false);
self::$_browser = $temp->getDefault(self::BROWSER, false);
self::$_environment = $temp->getDefault(self::ENVIRONMENT, false);
}
if ($locale == 'auto') {
$locale = self::$_auto;
}
if ($locale == 'browser') {
$locale = self::$_browser;
}
if ($locale == 'environment') {
$locale = self::$_environment;
}
if (is_array($locale)) {
$locale = key($locale);
}
if (array_key_exists($locale, self::$_localeData)) {
return $locale;
} else {
$locale = explode('_', $locale);
if (array_key_exists($locale[0], self::$_localeData)) {
return $locale[0];
}
}
return false;
}
示例9: getDefaultLocale
function getDefaultLocale($addRegion = false)
{
@(list($found, ) = array_keys(Zend_Locale::getDefault()));
if (!$found) {
return 'en_US';
}
if (!$addRegion) {
return $found;
}
return strlen($found) <= 4 ? ___('_default_locale') : $found;
}
示例10: getLanguage
public function getLanguage()
{
return Zend_Locale::getDefault();
}
示例11: testDefaultFramework
/**
* test getDefaultFramework
* expected true
*/
public function testDefaultFramework()
{
$value = new Zend_Locale();
$default = $value->getDefault(Zend_Locale::FRAMEWORK);
$this->assertTrue(is_array($default), 'No Default Locale found');
}
示例12: getLanguage
public function getLanguage()
{
$_list = $this->getLangaugeList();
$_locale = key(Zend_Locale::getDefault());
if (!array_key_exists($_locale, $_list)) {
list($_locale) = explode('_', $_locale);
}
return $_locale;
}
示例13: _getLocaleDate
/**
* Return Zend_Date object with browser sent|german locale.
*
* @param Zend_Date $timestamp
* @return Zend_Locale
*/
protected function _getLocaleDate(Zend_Date $date)
{
// TODO Get currently used locale in a better/easier way.
if (!self::$_locale) {
$currentLocales = Zend_Locale::getDefault();
self::$_locale = key($currentLocales);
}
$date = $date->setLocale(self::$_locale);
return $date;
}
示例14: get_locale
function get_locale()
{
$locale = new Zend_Locale();
return $locale->getDefault();
}