import v1.1.0_beta1 | 2009-08-21

This commit is contained in:
2019-07-17 22:16:19 +02:00
parent 2c1152f0d3
commit 8dee6b1a10
2306 changed files with 251360 additions and 23428 deletions

View File

@ -16,7 +16,7 @@
* @package Zend_Locale
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Locale.php 12063 2008-10-21 17:54:23Z thomas $
* @version $Id: Locale.php 15765 2009-05-25 19:59:45Z thomas $
*/
/**
@ -127,7 +127,7 @@ class Zend_Locale
*
* @var boolean
*/
public static $compatibilityMode = true;
public static $compatibilityMode = false;
/**
* Internal variable
@ -440,7 +440,7 @@ class Zend_Locale
/**
* Returns the language part of the locale
*
* @return language
* @return string Language
*/
public function getLanguage()
{
@ -465,7 +465,7 @@ class Zend_Locale
/**
* Return the accepted charset of the client
*
*
* @return string
*/
public static function getHttpCharset()
@ -731,7 +731,7 @@ class Zend_Locale
try {
$locale = self::_prepareLocale($locale, $strict);
} catch (Zend_Locale_Exception $e) {
return false;
return false;
}
if (($compatible === true) and (self::$compatibilityMode === true)) {
@ -758,11 +758,51 @@ class Zend_Locale
return false;
}
/**
* Finds the proper locale based on the input
* Checks if it exists, degrades it when necessary
* Detects registry locale and when all fails tries to detect a automatic locale
* Returns the found locale as string
*
* @param string $locale
* @throws Zend_Locale_Exception When the given locale is no locale or the autodetection fails
* @return string
*/
public static function findLocale($locale = null)
{
if ($locale === null) {
require_once 'Zend/Registry.php';
if (Zend_Registry::isRegistered('Zend_Locale')) {
$locale = Zend_Registry::get('Zend_Locale');
}
}
require_once 'Zend/Locale.php';
if ($locale === null) {
$locale = new Zend_Locale();
}
if (!Zend_Locale::isLocale($locale, true, false)) {
if (!Zend_Locale::isLocale($locale, false, false)) {
require_once 'Zend/Locale/Exception.php';
throw new Zend_Locale_Exception("The locale '$locale' is no known locale");
}
$locale = new Zend_Locale($locale);
}
if ($locale instanceof Zend_Locale) {
$locale = $locale->toString();
}
return $locale;
}
/**
* Returns a list of all known locales where the locale is the key
* Only real locales are returned, the internal locales 'root', 'auto', 'browser'
* and 'environment' are suppressed
*
*
* @return array List of all Locales
*/
public static function getLocaleList()
@ -833,6 +873,18 @@ class Zend_Locale
Zend_Locale_Data::clearCache();
}
/**
* Disables the set cache
*
* @param boolean $flag True disables any set cache, default is false
* @return void
*/
public static function disableCache($flag)
{
require_once 'Zend/Locale/Data.php';
Zend_Locale_Data::disableCache($flag);
}
/**
* Internal function, returns a single locale on detection
*
@ -843,6 +895,10 @@ class Zend_Locale
*/
private static function _prepareLocale($locale, $strict = false)
{
if ($locale instanceof Zend_Locale) {
$locale = $locale->toString();
}
if (is_array($locale)) {
return '';
}
@ -867,7 +923,7 @@ class Zend_Locale
$locale = self::$_default;
}
if (($locale === 'auto') or (empty($locale))) {
if (($locale === 'auto') or ($locale === null)) {
$locale = self::$_auto;
}
@ -877,7 +933,7 @@ class Zend_Locale
}
// This can only happen when someone extends Zend_Locale and erases the default
if ((empty($locale))) {
if ($locale === null) {
require_once 'Zend/Locale/Exception.php';
throw new Zend_Locale_Exception('Autodetection of Locale has been failed!');
}