Index: library/Zend/Locale.php =================================================================== --- library/Zend/Locale.php (Revision 9236) +++ library/Zend/Locale.php (Arbeitskopie) @@ -100,6 +100,7 @@ private static $_environment; private static $_Default = "en"; + private static $_Forced = null; /** * Generates a locale object @@ -253,6 +254,35 @@ /** + * Forces a default locale when not defined (no auto detection) + * + * @param String $locale + * @return boolean + * @throws Zend_Locale_Exception + */ + public static function setForcedDefault($locale) + { + if (($locale == "auto") or ($locale == "root") or + ($locale == "environment") or ($locale == "browser")) { + require_once 'Zend/Locale/Exception.php'; + throw new Zend_Locale_Exception('Only full qualified locales can be used as forced default!'); + } + if (array_key_exists($locale, self::$_localeData)) { + self::$_Forced = $locale; + return true; + } else { + $locale = explode('_', $locale); + if (array_key_exists($locale[0], self::$_localeData)) { + self::$_Forced = $locale[0]; + return true; + } + } + require_once 'Zend/Locale/Exception.php'; + throw new Zend_Locale_Exception("Unknown locale '$locale' can not be set as forced default!"); + } + + + /** * Expects the Systems standard locale * * For Windows: @@ -377,6 +407,10 @@ */ public function setLocale($locale = null) { + if ($locale === null && self::$_Forced !== null) { + $locale = self::$_Forced; + } + if (($locale == self::BROWSER) or ($locale == self::ENVIRONMENT) or ($locale === null)) { $locale = $this->getDefault($locale, true); }