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


PHP Zend_Locale::toString方法代码示例

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


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

示例1: loadFormData

 /**
  * Hook that loads the form data from $_POST or the model
  *
  * Or from whatever other source you specify here.
  */
 protected function loadFormData()
 {
     parent::loadFormData();
     $surveyId = $this->request->getParam(\MUtil_Model::REQUEST_ID);
     if (isset($this->formData['survey']) && $this->formData['survey'] && !$this->_survey instanceof \Gems_Tracker_Survey) {
         $this->_survey = $this->loader->getTracker()->getSurvey($this->formData['survey']);
     }
     if ($this->_survey instanceof \Gems_Tracker_Survey) {
         // Add (optional) survey specific translators
         $extraTrans = $this->importLoader->getAnswerImporters($this->_survey);
         if ($extraTrans) {
             $this->importTranslators = $extraTrans + $this->importTranslators;
             $this->_translatorDescriptions = false;
             $this->importModel->set('trans', 'multiOptions', $this->getTranslatorDescriptions());
         }
     }
     if ($this->_survey instanceof \Gems_Tracker_Survey) {
         $this->targetModel = $this->_survey->getAnswerModel($this->locale->toString());
         $this->importer->setTargetModel($this->targetModel);
         $source = $this->menu->getParameterSource();
         $source->offsetSet('gsu_has_pdf', $this->_survey->hasPdf() ? 1 : 0);
         $source->offsetSet('gsu_active', $this->_survey->isActive() ? 1 : 0);
     }
     // \MUtil_Echo::track($this->formData);
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:30,代码来源:AnswerImportSnippet.php

示例2: testDefaultLocale

    public function testDefaultLocale()
    {
        $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array());

        $defaultLocale = new Zend_Locale();
        $this->assertEquals($lang->getLocale(), $defaultLocale->toString());
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:7,代码来源:TranslateTest.php

示例3: revert

 /**
  * Get last locale, used before last emulation
  *
  */
 public function revert()
 {
     if ($locale = array_pop($this->_emulatedLocales)) {
         $this->_locale = $locale;
         $this->_localeCode = $this->_locale->toString();
         Mage::getSingleton('core/translate')->setLocale($this->_locale)->init('adminhtml', true);
     }
 }
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:12,代码来源:Locale.php

示例4: resolveLocale

 private function resolveLocale(\Zend_Locale $locale)
 {
     $proposed = array($locale->toString(), $locale->getLanguage(), self::DEFAULT_LANG);
     foreach ($proposed as $lang) {
         if (isset(self::$trans[$lang])) {
             return $lang;
         }
     }
 }
开发者ID:pago,项目名称:pantr,代码行数:9,代码来源:PeriodFormat.php

示例5: getRatingLink

 /**
  * This function returns the rating link for Trusted Shops.
  *
  * @param $tsID
  * @return string
  */
 private function getRatingLink($tsID)
 {
     $isoCode = $this->locale->toString();
     switch ($isoCode) {
         case 'de_DE':
             return 'https://www.trustedshops.de/bewertung/info_' . $tsID . '.html';
         case 'de_AT':
             return 'https://www.trustedshops.at/bewertung/info_' . $tsID . '.html';
         case 'de_CH':
             return 'https://www.trustedshops.ch/bewertung/info_' . $tsID . '.html';
         case 'fr_FR':
             return 'https://www.trustedshops.fr/evaluation/info_' . $tsID . '.html';
         case 'es_ES':
             return 'https://www.trustedshops.es/evaluacion/info_' . $tsID . '.html';
         case 'pl_PL':
             return 'https://www.trustedshops.pl/opinia/info_' . $tsID . '.html';
         default:
             return 'https://www.trustedshops.com/buyerrating/info_' . $tsID . '.html';
     }
 }
开发者ID:Goucher,项目名称:shopware,代码行数:26,代码来源:Config.php

示例6: confirmaremailAction

 public function confirmaremailAction()
 {
     self::requireIsPost();
     $code = trim($this->getRequest()->getParam('twucode'));
     if (!$_SESSION['twc']) {
         echo json_encode(array('status' => 0, 'msg' => _("Perdemos seu cadastro, volte e tente novamente.")));
         die;
     }
     if (strlen($code) != 6 || strtoupper($code) != $_SESSION['twc']['code']) {
         echo json_encode(array('status' => 0, 'msg' => _("O código não condiz com o que foi enviado por e-mail.")));
     } else {
         $locale = new Zend_Locale();
         Model_Usuario::getInstance()->cadastrar(array('locale' => $locale->toString(), 'nu_usuario' => uniqid(""), 'no_usuario' => $_SESSION['twc']['nome'], 'no_email' => $_SESSION['twc']['email'], 'tx_senha' => $_SESSION['twc']['senha']));
         $mailcontent = $this->view->partial('helpers/mail_novocadastro.phtml', $param);
         $mailcontent = $this->view->partial('helpers/mail_layout.phtml', array('title' => _("Trash Of WEB - Seja bem vindo!"), 'content' => $mailcontent));
         General::mail(array("email" => $_SESSION['twc']['email'], "title" => _("Trash Of WEB - Seja bem vindo!"), "content" => $mailcontent));
         General::login(array('no_email' => $_SESSION['twc']['email'], 'tx_senha' => $_SESSION['twc']['senha']));
         unset($_SESSION['twc']);
         echo json_encode(array('status' => 1, 'msg' => NULL));
     }
 }
开发者ID:clagomess,项目名称:trashofweb,代码行数:21,代码来源:ActionController.php

示例7: getLanguages

 /**
  * Returns a list of available translation languages
  * @param $detailed boolean Fetch additional info for translation
  * @return array List of translations
  */
 public function getLanguages($detailed = true)
 {
     $websiteConfigHelper = Zend_Controller_Action_HelperBroker::getExistingHelper('website');
     $languageIcons = Tools_Filesystem_Tools::findFilesByExtension($websiteConfigHelper->getPath() . $this->_langFlagsDir, 'png', false, true, false);
     $this->_languages = array();
     $loadedList = Zend_Registry::get('Zend_Translate')->getAdapter()->getList();
     foreach ($languageIcons as $country => $imgFile) {
         $locale = new Zend_Locale(Zend_Locale::getLocaleToTerritory($country));
         $lang = $locale->getLanguage();
         $langTitle = Zend_Locale::getTranslation($lang, 'language');
         if (!in_array($locale->getLanguage(), $loadedList)) {
             continue;
         }
         if ($detailed) {
             $this->_languages[$country] = array('locale' => $locale->toString(), 'language' => $langTitle, 'name' => $country, 'flag' => $this->_langFlagsDir . $imgFile);
         } else {
             $this->_languages[$country] = $langTitle;
         }
         unset($locale);
     }
     return $this->_languages;
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:27,代码来源:Language.php

示例8: testSetOption

 /**
  * test setOption
  * expected boolean
  */
 public function testSetOption()
 {
     $this->assertEquals(8, count(Zend_Locale_Format::setOptions(array('format_type' => 'php'))));
     $this->assertTrue(is_array(Zend_Locale_Format::setOptions()));
     try {
         $this->assertTrue(Zend_Locale_Format::setOptions(array('format_type' => 'xxx')));
         $this->fail("exception expected");
     } catch (Zend_Locale_Exception $e) {
         // success
     }
     try {
         $this->assertTrue(Zend_Locale_Format::setOptions(array('myformat' => 'xxx')));
         $this->fail("exception expected");
     } catch (Zend_Locale_Exception $e) {
         // success
     }
     $format = Zend_Locale_Format::setOptions(array('locale' => 'de', 'number_format' => Zend_Locale_FORMAT::STANDARD));
     $test = Zend_Locale_Data::getContent('de', 'decimalnumber');
     $this->assertEquals($test, $format['number_format']);
     try {
         $this->assertFalse(Zend_Locale_Format::setOptions(array('number_format' => array('x' => 'x'))));
         $this->fail("exception expected");
     } catch (Zend_Locale_Exception $e) {
         // success
     }
     $format = Zend_Locale_Format::setOptions(array('locale' => 'de', 'date_format' => Zend_Locale_Format::STANDARD));
     $test = Zend_Locale_Format::getDateFormat('de');
     $this->assertEquals($test, $format['date_format']);
     try {
         $this->assertFalse(Zend_Locale_Format::setOptions(array('date_format' => array('x' => 'x'))));
         $this->fail("exception expected");
     } catch (Zend_Locale_Exception $e) {
         // success
     }
     try {
         $this->assertFalse(is_array(Zend_Locale_Format::setOptions(array('fix_date' => 'no'))));
         $this->fail("exception expected");
     } catch (Zend_Locale_Exception $e) {
         // success
     }
     $format = Zend_Locale_Format::setOptions(array('locale' => Zend_Locale_Format::STANDARD));
     $locale = new Zend_Locale();
     $this->assertEquals($locale->toString(), $format['locale']);
     try {
         $this->assertFalse(is_array(Zend_Locale_Format::setOptions(array('locale' => 'nolocale'))));
         $this->fail("exception expected");
     } catch (Zend_Locale_Exception $e) {
         // success
     }
     try {
         $this->assertFalse(is_array(Zend_Locale_Format::setOptions(array('precision' => 50))));
         $this->fail("exception expected");
     } catch (Zend_Locale_Exception $e) {
         // success
     }
     // test interaction between class-wide default date format and using locale's default format
     try {
         $result = array('date_format' => 'MMM d, y', 'locale' => 'en_US', 'month' => '7', 'day' => '4', 'year' => '2007');
         Zend_Locale_Format::setOptions(array('format_type' => 'iso', 'date_format' => 'MMM d, y', 'locale' => 'en_US'));
         // test setUp
     } catch (Zend_Locale_Exception $e) {
         $this->fail("exception expected");
     }
     try {
         // uses global date_format with global locale
         $this->assertSame($result, Zend_Locale_Format::getDate('July 4, 2007'));
     } catch (Zend_Locale_Exception $e) {
         $this->fail("exception expected");
     }
     try {
         // uses global date_format with given locale
         $this->assertSame($result, Zend_Locale_Format::getDate('July 4, 2007', array('locale' => 'en_US')));
     } catch (Zend_Locale_Exception $e) {
         $this->fail("exception expected");
     }
     try {
         // sets a new global date format
         Zend_Locale_Format::setOptions(array('date_format' => 'M-d-y'));
     } catch (Zend_Locale_Exception $e) {
         $this->fail("exception expected");
     }
     try {
         // uses global date format with given locale
         // but this date format differs from the original set... (MMMM d, yyyy != M-d-y)
         $expected = Zend_Locale_Format::getDate('July 4, 2007', array('locale' => 'en_US'));
         $this->assertSame($expected['year'], $result['year']);
         $this->assertSame($expected['month'], $result['month']);
         $this->assertSame($expected['day'], $result['day']);
     } catch (Zend_Locale_Exception $e) {
         $this->fail("exception expected");
     }
     try {
         // the following should not be used... instead of null, Zend_Locale::ZFDEFAULT should be used
         // uses given local with standard format from this locale
         $this->assertSame($result, Zend_Locale_Format::getDate('July 4, 2007', array('locale' => 'en_US', 'date_format' => null)));
     } catch (Zend_Locale_Exception $e) {
//.........这里部分代码省略.........
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:101,代码来源:FormatTest.php

示例9: testsetLocaleFailedRoot

 /**
  * test setLocaleFailedRoot
  * expected true
  */
 public function testsetLocaleFailedRoot()
 {
     $value = new Zend_Locale();
     $value->setLocale('xx_AA');
     $this->assertEquals($value->toString(), 'root', 'Environment Locale not set');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:10,代码来源:LocaleTest.php

示例10: setLocale

 /**
  * Sets a new locale for data retreivement
  * Returned is the really set locale.
  * Example: 'de_XX' will be set to 'de' because 'de_XX' does not exist
  * 'xx_YY' will be set to 'root' because 'xx' does not exist
  *
  * @param  string|Zend_Locale     $locale  OPTIONAL Locale for parsing input
  * @return string
  */
 public function setLocale($locale = null)
 {
     if ($locale instanceof Zend_Locale) {
         $this->_locale = $locale->toString();
     } else {
         if (!($this->_locale = Zend_Locale::isLocale($locale, true))) {
             require_once 'Zend/Currency/Exception.php';
             throw new Zend_Currency_Exception("Given locale ({$locale}) does not exist");
         }
     }
     // get currency details
     $this->_options['currency'] = $this->getShortName(null, $this->_locale);
     $this->_options['name'] = $this->getName(null, $this->_locale);
     $this->_options['symbol'] = $this->getSymbol(null, $this->_locale);
     return $this->getLocale();
 }
开发者ID:dalinhuang,项目名称:popo,代码行数:25,代码来源:Currency.php

示例11: __construct

 /**
  * Creates a currency instance. Every supressed parameter is used from the actual or the given locale.
  *
  * @param  string              $currency  OPTIONAL currency short name
  * @param  string              $script    OPTIONAL script name
  * @param  string|Zend_Locale  $locale    OPTIONAL locale name
  * @return Zend_Currency
  * @throws Zend_Currency_Exception
  */
 public function __construct($currency = null, $script = null, $locale = null)
 {
     // supporting flexible parameters
     $params = array(1 => $currency, 2 => $locale, 3 => $script);
     foreach ($params as $num => $param) {
         // get the locale
         if ($param instanceof Zend_Locale) {
             $param = $param->toString();
         }
         if (($locale = Zend_Locale::isLocale($param)) && strlen($param) > 4) {
             if ($locale != $param) {
                 throw new Zend_Currency_Exception("Unknown locale or locale without a region passed");
             }
             if (!empty($this->_locale)) {
                 throw new Zend_Currency_Exception("Multiple locales passed. Please provide only one locale");
             }
             if ($param instanceof Zend_Locale) {
                 $param = $param->toString();
             }
             $this->_locale = $param;
             // get the currency short name
         } else {
             if (is_string($param) && strlen($param) == 3) {
                 if (!empty($this->_shortName)) {
                     throw new Zend_Currency_Exception("Multiple currencies passed. Please provide only one currency");
                 }
                 $this->_shortName = $param;
                 // get the script name
             } else {
                 if (is_string($param) && strlen($param) == 4) {
                     if (!empty($this->_script)) {
                         throw new Zend_Currency_Exception("Multiple number script names passed. Please provide only one script");
                     }
                     try {
                         Zend_Locale_Format::convertNumerals('0', $param);
                     } catch (Exception $e) {
                         throw new Zend_Currency_Exception($e->getMessage());
                     }
                     $this->_script = $param;
                     // unknown data passed in this param
                 } else {
                     if ($param !== null) {
                         throw new Zend_Currency_Exception("Unknown locale '{$param}' passed with param #{$num}, locale must include the region");
                     }
                 }
             }
         }
     }
     // if no locale is passed, use standard locale
     if (empty($this->_locale)) {
         $locale = new Zend_Locale();
         $this->_locale = $locale->toString();
     }
     // get/check the shortname
     $data = Zend_Locale_Data::getContent(null, 'currencyforregionlist');
     if (!empty($this->_shortName)) {
         if (!in_array($this->_shortName, $data)) {
             throw new Zend_Currency_Exception("Unknown currency '{$this->_shortName}' passed");
         }
     } else {
         if (array_key_exists(substr($this->_locale, strpos($this->_locale, '_') + 1), $data)) {
             $this->_shortName = $data[substr($this->_locale, strpos($this->_locale, '_') + 1)];
         }
     }
     // get the fullname
     $names = Zend_Locale_Data::getContent($this->_locale, 'currencynames', substr($this->_locale, strpos($this->_locale, '_') + 1));
     $this->_fullName = isset($names[$this->_shortName]) ? $names[$this->_shortName] : '';
     // get the symbol
     $symbols = Zend_Locale_Data::getContent($this->_locale, 'currencysymbols');
     $this->_symbol = isset($symbols[$this->_shortName]) ? $symbols[$this->_shortName] : '';
     // get the format
     $this->_updateFormat();
     $this->_usedSign = self::NO_SYMBOL;
     if (!empty($this->_symbol)) {
         $this->_usedSign = self::USE_SYMBOL;
     } else {
         if (!empty($this->_shortName)) {
             $this->_usedSign = self::USE_SHORTNAME;
         }
     }
     return $this;
 }
开发者ID:renatosoares,项目名称:blog-zend1,代码行数:91,代码来源:Currency.php

示例12: 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 (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;
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:31,代码来源:Locale.php

示例13: editAction

 public function editAction()
 {
     $this->view->locale = $locale = $this->_getParam('locale');
     $this->view->page = $page = $this->_getParam('page');
     $translate = Zend_Registry::get('Zend_Translate');
     try {
         if (!$locale || !Zend_Locale::findLocale($locale)) {
             throw new Exception('missing locale ' . $locale);
         }
     } catch (Exception $e) {
         return $this->_helper->redirector->gotoRoute(array('action' => 'index', 'controller' => 'language'), 'admin_default', true);
     }
     // Process filter form
     $this->view->filterForm = $filterForm = new Core_Form_Admin_Language_Filter();
     $filterForm->isValid($this->_getAllParams());
     $filterValues = $filterForm->getValues();
     extract($filterValues);
     // search, show
     // Make query
     $filterValues = array_filter($filterValues);
     $this->view->values = $filterValues;
     $this->view->query = empty($filterValues) ? '' : '?' . http_build_query($filterValues);
     // Assign basic locale info
     $this->view->localeObject = $localeObject = new Zend_Locale($locale);
     $this->view->locale = $locale = $localeObject->toString();
     // Get locale translation info
     $localeLanguage = $localeObject->getLanguage();
     $localeRegion = $localeObject->getRegion();
     $this->view->localeLanguageTranslation = $localeLanguageTranslation = Zend_Locale::getTranslation($localeLanguage, 'language', Zend_Registry::get('Locale'));
     $this->view->localeRegionTranslation = $localeRegionTranslation = Zend_Locale::getTranslation($localeRegion, 'territory', Zend_Registry::get('Locale'));
     $translate = Zend_Registry::get('Zend_Translate');
     if ($localeLanguageTranslation && $localeRegionTranslation) {
         $this->view->localeTranslation = $localeLanguageTranslation . ' ' . sprintf($translate->translate('(%s)'), $localeRegionTranslation) . ' ' . sprintf($translate->translate('[%s]'), $locale);
     } else {
         if ($localeLanguageTranslation) {
             $this->view->localeTranslation = $localeLanguageTranslation . ' ' . sprintf($translate->translate('[%s]'), $locale);
         } else {
             $this->view->localeTranslation = sprintf($translate->translate('[%s]'), $locale);
         }
     }
     // Query plural system for max and sample space
     $sample = array();
     $max = 0;
     for ($i = 0; $i <= 1000; $i++) {
         $form = Zend_Translate_Plural::getPlural($i, $locale);
         $max = max($max, $form);
         if (@count($sample[$form]) < 3) {
             $sample[$form][] = $i;
         }
     }
     $this->view->pluralFormCount = $max + 1;
     $this->view->pluralFormSample = $sample;
     // Get initial and default values
     $baseMessages = $translate->getMessages('en');
     if ($translate->isAvailable($locale)) {
         $currentMessages = $translate->getMessages($locale);
     } else {
         $currentMessages = array();
         // @todo this should redirect or smth
     }
     // Get phrases that are not in the english pack?
     if (!empty($currentMessages) && $locale != 'en') {
         $missingBasePhrases = array_diff_key($currentMessages, $baseMessages);
         $missingBasePhrases = array_combine(array_keys($missingBasePhrases), array_keys($missingBasePhrases));
         $baseMessages = array_merge($baseMessages, $missingBasePhrases);
     }
     // Build the fancy array
     $resultantMessages = array();
     $missing = 0;
     $index = 0;
     foreach ($baseMessages as $key => $value) {
         // Build
         $composite = array('uid' => ++$index, 'key' => $key, 'original' => $value, 'plural' => (bool) is_array($value));
         // filters, plurals, and missing, oh my.
         if (isset($currentMessages[$key])) {
             if ('missing' == $show) {
                 continue;
             }
             if (is_array($value) && !is_array($currentMessages[$key])) {
                 $composite['current'] = array($currentMessages[$key]);
             } else {
                 if (!is_array($value) && is_array($currentMessages[$key])) {
                     $composite['current'] = current($currentMessages[$key]);
                 } else {
                     $composite['current'] = $currentMessages[$key];
                 }
             }
         } else {
             if ('translated' == $show) {
                 continue;
             }
             if (is_array($value)) {
                 $composite['current'] = array();
             } else {
                 $composite['current'] = '';
             }
             $missing++;
         }
         // Do search
         if ($search && !$this->_searchArrayRecursive($search, $composite)) {
//.........这里部分代码省略.........
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:101,代码来源:AdminLanguageController.php

示例14: setLocale

 /**
  * Set the locale the useragent had set.
  *
  * @param Zend-Locale $locale
  *
  * @return ShortUrl_Model_Call
  */
 public function setLocale(Zend_Locale $locale = null)
 {
     if (null === $locale) {
         $locale = new Zend_Locale();
     }
     $this->_locale = $locale->toString();
     return $this;
 }
开发者ID:heiglandreas,项目名称:ShortURL,代码行数:15,代码来源:Call.php

示例15: testTerritoryToGetLocale

 /**
  * @ZF-9488
  */
 public function testTerritoryToGetLocale()
 {
     $value = Zend_Locale::findLocale('US');
     $this->assertEquals('en_US', $value);
     $value = new Zend_Locale('US');
     $this->assertEquals('en_US', $value->toString());
     $value = new Zend_Locale('TR');
     $this->assertEquals('tr_TR', $value->toString());
 }
开发者ID:netvlies,项目名称:zf,代码行数:12,代码来源:LocaleTest.php


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