本文整理汇总了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();
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}