public static function resolve(array $availableLocales, $locale, $fallbackLocale = null)
    {
        $locale = self::canonicalize($locale);
        $resolvedLocale = null;
        foreach (self::getCandidates($locale, $fallbackLocale) as $candidate) {
            if (in_array($candidate, $availableLocales)) {
                $resolvedLocale = $candidate;
                break;
            }
        }
        // No locale could be resolved, stop here.
        if (!$resolvedLocale) {
            throw new UnknownLocaleException($locale);
        }

        return $resolvedLocale;
    }
public static function resolve(array $availableLocales, $locale, $fallbackLocale = null)
    {
        $locale = self::canonicalize($locale);
        $resolvedLocale = null;
        foreach (self::getCandidates($locale, $fallbackLocale) as $candidate) {
            if (in_array($candidate, $availableLocales)) {
                $resolvedLocale = $candidate;
                break;
            }
        }
        // No locale could be resolved, stop here.
        if (!$resolvedLocale) {
            throw new UnknownLocaleException($locale);
        }

        return $resolvedLocale;
    }
public static function resolve ( array $ availableLocales , $ locale , $ fallbackLocale = null ) { $ locale = self :: canonicalize ( $ locale ) ; $ resolvedLocale = null ; foreach ( self :: getCandidates ( $ locale , $ fallbackLocale ) as $ candidate ) { if ( in_array ( $ candidate , $ availableLocales ) ) { $ resolvedLocale = $ candidate ; break ; } } // No locale could be resolved, stop here. if ( ! $ resolvedLocale ) { throw new UnknownLocaleException ( $ locale ) ; } return $ resolvedLocale ; }
Resolves the locale from the available locales.

Takes all locale candidates for the requested locale
and fallback locale, searches for them in the available
locale list. The first found locale is returned.
If no candidate is found in the list, an exception is thrown.

@see self::getCandidates

@param array  $availableLocales The available locales.
@param string $locale           The requested locale (i.e. fr-FR).
@param string $fallbackLocale   A fallback locale (i.e "en").

@return string

@throws UnknownLocaleException
Resolves the locale from the available locales .