/** * 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\InvalidArgumentException When the given locale is no locale or the autodetection fails * @return string */ public static function findLocale($locale = null) { if ($locale === null) { if (Registry::isRegistered('Zend_Locale')) { $locale = Registry::get('Zend_Locale'); } } if ($locale === null) { $locale = new Locale(); } if (!Locale::isLocale($locale, true)) { if (!Locale::isLocale($locale, false)) { $locale = Locale::getLocaleToTerritory($locale); if (empty($locale)) { throw new Exception\InvalidArgumentException("The locale '{$locale}' is no known locale"); } } else { $locale = new self($locale); } } $locale = self::_prepareLocale($locale); return $locale; }