public static function countryLocaleCode($countryCode)
    {
        $countryLocaleCodes = static::countryLocaleCodes($countryCode);
        if ($languageCode = Language::countryLanguageCode($countryCode)) {
            $languageLocaleCodes = static::languageLocaleCodes($languageCode);
            if ($localeCodes = array_intersect($languageLocaleCodes, $countryLocaleCodes)) {
                return reset($localeCodes);
            } elseif ($countryLocaleCodes) {
                return reset($countryLocaleCodes);
            } elseif ($languageLocaleCodes) {
                return reset($languageLocaleCodes);
            }

            return \Locale::composeLocale([
                'language' => $languageCode,
                'region' => $countryCode,
            ]);
        }

        if (!count($countryLocaleCodes)) {
            return null;
        } elseif (count($countryLocaleCodes) == 1) {
            return reset($countryLocaleCodes);
        }

        if ($localeCode = static::findMainCode($countryLocaleCodes)) {
            return $localeCode;
        }

        foreach ($countryLocaleCodes as $localeCode) {
            $languageCode = static::languageCode($localeCode);
            if (!strcasecmp($languageCode, $countryCode)) {
                return $localeCode;
            }
        }

        return reset($countryLocaleCodes);
    }
public static function countryLocaleCode($countryCode)
    {
        $countryLocaleCodes = static::countryLocaleCodes($countryCode);
        if ($languageCode = Language::countryLanguageCode($countryCode)) {
            $languageLocaleCodes = static::languageLocaleCodes($languageCode);
            if ($localeCodes = array_intersect($languageLocaleCodes, $countryLocaleCodes)) {
                return reset($localeCodes);
            } elseif ($countryLocaleCodes) {
                return reset($countryLocaleCodes);
            } elseif ($languageLocaleCodes) {
                return reset($languageLocaleCodes);
            }

            return \Locale::composeLocale([
                'language' => $languageCode,
                'region' => $countryCode,
            ]);
        }

        if (!count($countryLocaleCodes)) {
            return null;
        } elseif (count($countryLocaleCodes) == 1) {
            return reset($countryLocaleCodes);
        }

        if ($localeCode = static::findMainCode($countryLocaleCodes)) {
            return $localeCode;
        }

        foreach ($countryLocaleCodes as $localeCode) {
            $languageCode = static::languageCode($localeCode);
            if (!strcasecmp($languageCode, $countryCode)) {
                return $localeCode;
            }
        }

        return reset($countryLocaleCodes);
    }
public static function countryLocaleCode ( $ countryCode ) { $ countryLocaleCodes = static :: countryLocaleCodes ( $ countryCode ) ; if ( $ languageCode = Language :: countryLanguageCode ( $ countryCode ) ) { $ languageLocaleCodes = static :: languageLocaleCodes ( $ languageCode ) ; if ( $ localeCodes = array_intersect ( $ languageLocaleCodes , $ countryLocaleCodes ) ) { return reset ( $ localeCodes ) ; } elseif ( $ countryLocaleCodes ) { return reset ( $ countryLocaleCodes ) ; } elseif ( $ languageLocaleCodes ) { return reset ( $ languageLocaleCodes ) ; } return \ Locale :: composeLocale ( [ 'language' => $ languageCode , 'region' => $ countryCode , ] ) ; } if ( ! count ( $ countryLocaleCodes ) ) { return null ; } elseif ( count ( $ countryLocaleCodes ) == 1 ) { return reset ( $ countryLocaleCodes ) ; } if ( $ localeCode = static :: findMainCode ( $ countryLocaleCodes ) ) { return $ localeCode ; } foreach ( $ countryLocaleCodes as $ localeCode ) { $ languageCode = static :: languageCode ( $ localeCode ) ; if ( ! strcasecmp ( $ languageCode , $ countryCode ) ) { return $ localeCode ; } } return reset ( $ countryLocaleCodes ) ; }
Tries to find locale code for a country
@param string $countryCode the ISO 3166-1 alpha-2 country code
@return string|null locale code (using RFC 4646 language tags)
Tries to find locale code for a country