public function getParentLocaleOf(Locale $locale)
    {
        $localeIdentifier = (string)$locale;

        if (!isset($this->localeCollection[$localeIdentifier])) {
            return null;
        }

        if (isset($this->localeParentCollection[$localeIdentifier])) {
            return $this->localeParentCollection[$localeIdentifier];
        }

        $parentLocaleIdentifier = $localeIdentifier;
        do {
            // Remove the last (most specific) part of the locale tag
            $parentLocaleIdentifier = substr($parentLocaleIdentifier, 0, (int)strrpos($parentLocaleIdentifier, '_'));

            if (isset($this->localeCollection[$parentLocaleIdentifier])) {
                return $this->localeParentCollection[$localeIdentifier] = $this->localeCollection[$parentLocaleIdentifier];
            }
        } while (strrpos($parentLocaleIdentifier, '_') !== false);

        return null;
    }
public function getParentLocaleOf(Locale $locale)
    {
        $localeIdentifier = (string)$locale;

        if (!isset($this->localeCollection[$localeIdentifier])) {
            return null;
        }

        if (isset($this->localeParentCollection[$localeIdentifier])) {
            return $this->localeParentCollection[$localeIdentifier];
        }

        $parentLocaleIdentifier = $localeIdentifier;
        do {
            // Remove the last (most specific) part of the locale tag
            $parentLocaleIdentifier = substr($parentLocaleIdentifier, 0, (int)strrpos($parentLocaleIdentifier, '_'));

            if (isset($this->localeCollection[$parentLocaleIdentifier])) {
                return $this->localeParentCollection[$localeIdentifier] = $this->localeCollection[$parentLocaleIdentifier];
            }
        } while (strrpos($parentLocaleIdentifier, '_') !== false);

        return null;
    }
public function getParentLocaleOf ( Locale $ locale ) { $ localeIdentifier = ( string ) $ locale ; if ( ! isset ( $ this -> localeCollection [ $ localeIdentifier ] ) ) { return null ; } if ( isset ( $ this -> localeParentCollection [ $ localeIdentifier ] ) ) { return $ this -> localeParentCollection [ $ localeIdentifier ] ; } $ parentLocaleIdentifier = $ localeIdentifier ; do { // Remove the last (most specific) part of the locale tag $ parentLocaleIdentifier = substr ( $ parentLocaleIdentifier , 0 , ( int ) strrpos ( $ parentLocaleIdentifier , '_' ) ) ; if ( isset ( $ this -> localeCollection [ $ parentLocaleIdentifier ] ) ) { return $ this -> localeParentCollection [ $ localeIdentifier ] = $ this -> localeCollection [ $ parentLocaleIdentifier ] ; } } while ( strrpos ( $ parentLocaleIdentifier , '_' ) !== false ) ; return null ; }
Returns a parent Locale object of the locale provided.

The parent is a locale which is more generic than the one given as
parameter. For example, the parent for locale en_GB will be locale en, of
course if it exists in the locale tree of available locales.

This method returns NULL when no parent locale is available, or when
Locale object provided is not in the tree (ie it's not in a group of
available locales).

Note: to find a best-matching locale to one which doesn't exist in the
system, please use findBestMatchingLocale() method of this class.

@param Locale $locale The Locale to search parent for
@return mixed Existing Locale instance or NULL on failure
Returns a parent Locale object of the locale provided .