public static function getAllCountriesForLocale($locale)
    {
        $dataDir = __DIR__ . DIRECTORY_SEPARATOR . static::$dataDir;
        $regionList = require $dataDir . '_list.php';

        if (!isset($regionList[$locale])) {
            throw new \RuntimeException("Locale is not supported");
        }

        /*
         * Loop through each part of the $locale, and load data for that locale
         *
         * E.g zh-Hans-HK will look for zh-Hanks-HK, zh-Hanks, then finally zh
         */
        $fallbackParts = explode('-', str_replace('_', '-', $locale));
        $filesToSearch = array();

        $i = count($fallbackParts);
        while ($i > 0) {
            $searchLocale = strtolower(implode('-', $fallbackParts));

            if (isset($regionList[$searchLocale])) {
                $filesToSearch[] = $searchLocale;
            }

            array_pop($fallbackParts);
            $i--;
        }

        /*
         * Load data files, and load the region (if it exists) from it
         */

        $returnData = array();

        foreach ($filesToSearch as $fileToSearch) {
            // Load data file
            $data = require $dataDir . $fileToSearch . '.php';

            $returnData += $data;
        }

        ksort($returnData);

        return $returnData;
    }
public static function getAllCountriesForLocale($locale)
    {
        $dataDir = __DIR__ . DIRECTORY_SEPARATOR . static::$dataDir;
        $regionList = require $dataDir . '_list.php';

        if (!isset($regionList[$locale])) {
            throw new \RuntimeException("Locale is not supported");
        }

        /*
         * Loop through each part of the $locale, and load data for that locale
         *
         * E.g zh-Hans-HK will look for zh-Hanks-HK, zh-Hanks, then finally zh
         */
        $fallbackParts = explode('-', str_replace('_', '-', $locale));
        $filesToSearch = array();

        $i = count($fallbackParts);
        while ($i > 0) {
            $searchLocale = strtolower(implode('-', $fallbackParts));

            if (isset($regionList[$searchLocale])) {
                $filesToSearch[] = $searchLocale;
            }

            array_pop($fallbackParts);
            $i--;
        }

        /*
         * Load data files, and load the region (if it exists) from it
         */

        $returnData = array();

        foreach ($filesToSearch as $fileToSearch) {
            // Load data file
            $data = require $dataDir . $fileToSearch . '.php';

            $returnData += $data;
        }

        ksort($returnData);

        return $returnData;
    }
public static function getAllCountriesForLocale ( $ locale ) { $ dataDir = __DIR__ . DIRECTORY_SEPARATOR . static :: $ dataDir ; $ regionList = require $ dataDir . '_list.php' ; if ( ! isset ( $ regionList [ $ locale ] ) ) { throw new \ RuntimeException ( "Locale is not supported" ) ; } /*
         * Loop through each part of the $locale, and load data for that locale
         *
         * E.g zh-Hans-HK will look for zh-Hanks-HK, zh-Hanks, then finally zh
         */ $ fallbackParts = explode ( '-' , str_replace ( '_' , '-' , $ locale ) ) ; $ filesToSearch = array ( ) ; $ i = count ( $ fallbackParts ) ; while ( $ i > 0 ) { $ searchLocale = strtolower ( implode ( '-' , $ fallbackParts ) ) ; if ( isset ( $ regionList [ $ searchLocale ] ) ) { $ filesToSearch [ ] = $ searchLocale ; } array_pop ( $ fallbackParts ) ; $ i -- ; } /*
         * Load data files, and load the region (if it exists) from it
         */ $ returnData = array ( ) ; foreach ( $ filesToSearch as $ fileToSearch ) { // Load data file $ data = require $ dataDir . $ fileToSearch . '.php' ; $ returnData += $ data ; } ksort ( $ returnData ) ; return $ returnData ; }
Load a list of all countries supported by a particular Locale

@param string $locale
@return string[] Associative array of Country Code => Country Name
@throws \RuntimeException On an invalid region
Load a list of all countries supported by a particular Locale