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


PHP Locales::getAvailableLocales方法代码示例

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


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

示例1: find

 /**
  * provides default parameters for the FileFinder::find() method
  *
  * @see FileFinder::find()
  * @return An array with the new locales found in the disk
  */
 function find()
 {
     // first find the new ones
     parent::find(Locales::getAvailableLocales(), "locale_*.php");
     // and then return them, if any
     return $this->getNew();
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:13,代码来源:localefinder.class.php

示例2: _matchHttpAcceptLanguages

 /**
  * Tries to match the prefered language out of the http_accept_language string 
  * with one of the available languages.
  *
  * @private
  * @param httpAcceptLanguage the value of $_SERVER['HTTP_ACCEPT_LANGUAGE']
  * @return Returns returns prefered language or false if no language matched.
  */
 function _matchHttpAcceptLanguages(&$httpAcceptLanguage)
 {
     $acceptedLanguages = explode(',', $httpAcceptLanguage);
     $availableLanguages =& Locales::getAvailableLocales();
     $primaryLanguageMatch = '';
     // we iterate through the array of languages sent by the UA and test every single
     // one against the array of available languages
     foreach ($acceptedLanguages as $acceptedLang) {
         // clean the string and strip it down to the language value (remove stuff like ";q=0.3")
         $acceptedLang = substr($acceptedLang, 0, strcspn($acceptedLang, ';'));
         if (strlen($acceptedLang) > 2) {
             // cut to primary language
             $primaryAcceptedLang = substr($acceptedLang, 0, 2);
         } else {
             $primaryAcceptedLang = $acceptedLang;
         }
         // this is where we start to iterate through available languages
         foreach ($availableLanguages as $availableLang) {
             if (stristr($availableLang, $acceptedLang) !== false) {
                 // we have a exact language match
                 return $availableLang;
             } elseif (stristr($availableLang, $primaryAcceptedLang) !== false && $primaryLanguageMatch == '') {
                 // we found the first primary language match!
                 $primaryLanguageMatch = $availableLang;
             }
         }
     }
     // foreach
     if ($primaryLanguageMatch != '') {
         return $primaryLanguageMatch;
     } else {
         return false;
     }
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:42,代码来源:summaryaction.class.php

示例3: Locales

 /**
  * @private
  */
 function _deleteLocales()
 {
     $locales = new Locales();
     // if there is only one locale available in the system, we should
     // not allow to remove it either
     if (count($locales->getAvailableLocales()) == 1) {
         $this->_view = new AdminSiteLocalesListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_deleting_only_locale"));
         $this->setCommonData();
         return false;
     }
     // keep the value of the default locale because plog should not allow
     // to remove the default one
     $defaultLocale = $this->_config->getValue("default_locale");
     $errorMessage = "";
     $successMessage = "";
     $totalOk = 0;
     foreach ($this->_localeIds as $localeId) {
         if ($localeId != $defaultLocale) {
             if ($locales->removeLocale($localeId)) {
                 $totalOk++;
                 if ($totalOk < 2) {
                     $successMessage = $this->_locale->pr("locale_deleted_ok", $localeId);
                 } else {
                     $successMessage = $this->_locale->pr("locales_deleted_ok", $totalOk);
                 }
             } else {
                 $errorMessage .= $this->_locale->pr("error_deleting_locale", $localeId) . "<br/>";
             }
         } else {
             $errorMessage .= $this->_locale->pr("error_locale_is_default", $localeId) . "<br/>";
         }
     }
     $this->_view = new AdminSiteLocalesListView($this->_blogInfo);
     if ($errorMessage != "") {
         $this->_view->setErrorMessage($errorMessage);
     }
     if ($successMessage != "") {
         $this->_view->setSuccessMessage($successMessage);
     }
     $this->setCommonData();
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:46,代码来源:admindeletelocalesaction.class.php

示例4: validate

 function validate()
 {
     // all the seettings come from a very nice array from the html form
     $this->_newConfigOpts = array();
     $this->_newConfigOpts = $this->_request->getValue("config");
     // the xmlrpc_ping_hosts requires special treatment, since we need to
     // split the input returned from the textbox into an array
     if (isset($this->_newConfigOpts["xmlrpc_ping_hosts"])) {
         $array = array();
         foreach (explode("\r\n", $this->_newConfigOpts["xmlrpc_ping_hosts"]) as $host) {
             trim($host);
             if ($host != "" && $host != "\r\n" && $host != "\r" && $host != "\n") {
                 array_push($array, $host);
             }
         }
         $this->_newConfigOpts["xmlrpc_ping_hosts"] = $array;
     }
     // the 'locales' and 'arrays' settings are not coming from the request
     $configOpts = $this->_config->getAsArray();
     $locales = new Locales();
     $this->_newConfigOpts["locales"] = $locales->getAvailableLocales();
     $this->_newConfigOpts["templates"] = $configOpts["templates"];
     return true;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:24,代码来源:adminupdateglobalsettingsaction.class.php

示例5: getLocales

 /**
  * Returns an array with all the locales available in the system.
  *
  * This is quite memory and disk-intensive since we are loading a lot of lines
  * from possibly a lot of files!!!
  *
  * @return Returns an array of Locale objects, which represent *all* the locales
  * that have been installed in this system.
  * @static
  */
 function getLocales()
 {
     $localeCodes = Locales::getAvailableLocales();
     $locales = array();
     foreach ($localeCodes as $code) {
         array_push($locales, new Locale($code));
     }
     return $locales;
 }
开发者ID:BackupTheBerlios,项目名称:plogfr-svn,代码行数:19,代码来源:locales.class.php


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