Returns a region name for a country code + region code.

@param string $countryCode
@param string $regionCode
@return string The region name or 'Unknown' (translated).
503288
public static function getRegionNameFromCodes($countryCode, $regionCode)
    {
        $regionNames = self::getRegionNames();

        $countryCode = strtoupper($countryCode);
        $regionCode = strtoupper($regionCode);

        if (isset($regionNames[$countryCode][$regionCode])) {
            return $regionNames[$countryCode][$regionCode];
        } else {
            return Piwik::translate('General_Unknown');
        }
    }
1092262
public static function getCountryName($iso_code)
    {
        if (isset(self::$countries[$iso_code])) {
            return self::$countries[$iso_code];
        }

        return false;
    }
724038
public function getCountryCodeMapping()
    {
        $regionDataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\RegionDataProvider');

        $countryCodeList = $regionDataProvider->getCountryList();

        array_walk($countryCodeList, function(&$item, $key) {
            $item = Piwik::translate('Intl_Country_'.strtoupper($key));
        });

        return $countryCodeList;
    }
367986
protected function getCountryNameForNumber(PhoneNumber $number, $locale)
    {
        $regionCodes = $this->phoneUtil->getRegionCodesForCountryCode($number->getCountryCode());

        if (count($regionCodes) === 1) {
            return $this->getRegionDisplayName($regionCodes[0], $locale);
        }

        $regionWhereNumberIsValid = 'ZZ';
        foreach ($regionCodes as $regionCode) {
            if ($this->phoneUtil->isValidNumberForRegion($number, $regionCode)) {
                // If the number has already been found valid for one region, then we don't know which
                // region it belongs to so we return nothing.
                if ($regionWhereNumberIsValid !== 'ZZ') {
                    return '';
                }
                $regionWhereNumberIsValid = $regionCode;
            }
        }

        return $this->getRegionDisplayName($regionWhereNumberIsValid, $locale);
    }
1159089
protected function rawInputContainsNationalPrefix($rawInput, $nationalPrefix, $regionCode)
    {
        $normalizedNationalNumber = static::normalizeDigitsOnly($rawInput);
        if (strpos($normalizedNationalNumber, $nationalPrefix) === 0) {
            try {
                // Some Japanese numbers (e.g. 00777123) might be mistaken to contain the national prefix
                // when written without it (e.g. 0777123) if we just do prefix matching. To tackle that, we
                // check the validity of the number if the assumed national prefix is removed (777123 won't
                // be valid in Japan).
                return $this->isValidNumber(
                    $this->parse(substr($normalizedNationalNumber, mb_strlen($nationalPrefix)), $regionCode)
                );
            } catch (NumberParseException $e) {
                return false;
            }
        }
        return false;
    }
129575
public function getParkingRate($countryCode)
    {
        $country = $this->getCountry($countryCode);
        if (!is_null($country)) {
            return $country->getParkingRate();
        }

        return null;
    }
985503
public function getCountry($countryCode)
    {
        // accept lowercase country codes
        $countryCode = strtoupper($countryCode);

        $result = current(array_filter($this->countries, function ($country) use ($countryCode) {
            /** @var VATCountry $country */
            return ($country->getCode() == $countryCode || $country->getCountryCode() == $countryCode);
        }));

        return $result != false ? $result : null;
    }
49751
public function getSuperReducedRate($countryCode)
    {
        $country = $this->getCountry($countryCode);
        if (!is_null($country)) {
            return $country->getSuperReducedRate();
        }

        return null;
    }
1104243
public static function country2locale($code) {
    # http://wiki.openstreetmap.org/wiki/Nominatim/Country_Codes
    $arr = array(
      'ad' => 'ca',
      'ae' => 'ar',
      'af' => 'fa,ps',
      'ag' => 'en',
      'ai' => 'en',
      'al' => 'sq',
      'am' => 'hy',
      'an' => 'nl,en',
      'ao' => 'pt',
      'aq' => 'en',
      'ar' => 'es',
      'as' => 'en,sm',
      'at' => 'de',
      'au' => 'en',
      'aw' => 'nl,pap',
      'ax' => 'sv',
      'az' => 'az',
      'ba' => 'bs,hr,sr',
      'bb' => 'en',
      'bd' => 'bn',
      'be' => 'nl,fr,de',
      'bf' => 'fr',
      'bg' => 'bg',
      'bh' => 'ar',
      'bi' => 'fr',
      'bj' => 'fr',
      'bl' => 'fr',
      'bm' => 'en',
      'bn' => 'ms',
      'bo' => 'es,qu,ay',
      'br' => 'pt',
      'bq' => 'nl,en',
      'bs' => 'en',
      'bt' => 'dz',
      'bv' => 'no',
      'bw' => 'en,tn',
      'by' => 'be,ru',
      'bz' => 'en',
      'ca' => 'en,fr',
      'cc' => 'en',
      'cd' => 'fr',
      'cf' => 'fr',
      'cg' => 'fr',
      'ch' => 'de,fr,it,rm',
      'ci' => 'fr',
      'ck' => 'en,rar',
      'cl' => 'es',
      'cm' => 'fr,en',
      'cn' => 'zh',
      'co' => 'es',
      'cr' => 'es',
      'cu' => 'es',
      'cv' => 'pt',
      'cw' => 'nl',
      'cx' => 'en',
      'cy' => 'el,tr',
      'cz' => 'cs',
      'de' => 'de',
      'dj' => 'fr,ar,so',
      'dk' => 'da',
      'dm' => 'en',
      'do' => 'es',
      'dz' => 'ar',
      'ec' => 'es',
      'ee' => 'et',
      'eg' => 'ar',
      'eh' => 'ar,es,fr',
      'er' => 'ti,ar,en',
      'es' => 'es,ast,ca,eu,gl',
      'et' => 'am,om',
      'fi' => 'fi,sv,se',
      'fj' => 'en',
      'fk' => 'en',
      'fm' => 'en',
      'fo' => 'fo',
      'fr' => 'fr',
      'ga' => 'fr',
      'gb' => 'en,ga,cy,gd,kw',
      'gd' => 'en',
      'ge' => 'ka',
      'gf' => 'fr',
      'gg' => 'en',
      'gh' => 'en',
      'gi' => 'en',
      'gl' => 'kl,da',
      'gm' => 'en',
      'gn' => 'fr',
      'gp' => 'fr',
      'gq' => 'es,fr,pt',
      'gr' => 'el',
      'gs' => 'en',
      'gt' => 'es',
      'gu' => 'en,ch',
      'gw' => 'pt',
      'gy' => 'en',
      'hk' => 'zh,en',
      'hm' => 'en',
      'hn' => 'es',
      'hr' => 'hr',
      'ht' => 'fr,ht',
      'hu' => 'hu',
      'id' => 'id',
      'ie' => 'en,ga',
      'il' => 'he',
      'im' => 'en',
      'in' => 'hi,en',
      'io' => 'en',
      'iq' => 'ar,ku',
      'ir' => 'fa',
      'is' => 'is',
      'it' => 'it,de,fr',
      'je' => 'en',
      'jm' => 'en',
      'jo' => 'ar',
      'jp' => 'ja',
      'ke' => 'sw,en',
      'kg' => 'ky,ru',
      'kh' => 'km',
      'ki' => 'en',
      'km' => 'ar,fr',
      'kn' => 'en',
      'kp' => 'ko',
      'kr' => 'ko,en',
      'kw' => 'ar',
      'ky' => 'en',
      'kz' => 'kk,ru',
      'la' => 'lo',
      'lb' => 'ar,fr',
      'lc' => 'en',
      'li' => 'de',
      'lk' => 'si,ta',
      'lr' => 'en',
      'ls' => 'en,st',
      'lt' => 'lt',
      'lu' => 'lb,fr,de',
      'lv' => 'lv',
      'ly' => 'ar',
      'ma' => 'ar',
      'mc' => 'fr',
      'md' => 'ru,uk,ro',
      'me' => 'srp,sq,bs,hr,sr',
      'mf' => 'fr',
      'mg' => 'mg,fr',
      'mh' => 'en,mh',
      'mk' => 'mk',
      'ml' => 'fr',
      'mm' => 'my',
      'mn' => 'mn',
      'mo' => 'zh,en,pt',
      'mp' => 'ch',
      'mq' => 'fr',
      'mr' => 'ar,fr',
      'ms' => 'en',
      'mt' => 'mt,en',
      'mu' => 'mfe,fr,en',
      'mv' => 'dv',
      'mw' => 'en,ny',
      'mx' => 'es',
      'my' => 'ms,zh,en',
      'mz' => 'pt',
      'na' => 'en,sf,de',
      'nc' => 'fr',
      'ne' => 'fr',
      'nf' => 'en,pih',
      'ng' => 'en',
      'ni' => 'es',
      'nl' => 'nl',
      'no' => 'nb,nn,no,se',
      'np' => 'ne',
      'nr' => 'na,en',
      'nu' => 'niu,en',
      'nz' => 'en,mi',
      'om' => 'ar',
      'pa' => 'es',
      'pe' => 'es',
      'pf' => 'fr',
      'pg' => 'en,tpi,ho',
      'ph' => 'en,tl',
      'pk' => 'en,ur',
      'pl' => 'pl',
      'pm' => 'fr',
      'pn' => 'en,pih',
      'pr' => 'es,en',
      'ps' => 'ar,he',
      'pt' => 'pt',
      'pw' => 'en,pau,ja,sov,tox',
      'py' => 'es,gn',
      'qa' => 'ar',
      're' => 'fr',
      'ro' => 'ro',
      'rs' => 'sr',
      'ru' => 'ru',
      'rw' => 'rw,fr,en',
      'sa' => 'ar',
      'sb' => 'en',
      'sc' => 'fr,en,crs',
      'sd' => 'ar,en',
      'se' => 'sv',
      'sg' => 'en,ms,zh,ta',
      'sh' => 'en',
      'si' => 'sl',
      'sj' => 'no',
      'sk' => 'sk',
      'sl' => 'en',
      'sm' => 'it',
      'sn' => 'fr',
      'so' => 'so,ar',
      'sr' => 'nl',
      'st' => 'pt',
      'ss' => 'en',
      'sv' => 'es',
      'sx' => 'nl,en',
      'sy' => 'ar',
      'sz' => 'en,ss',
      'tc' => 'en',
      'td' => 'fr,ar',
      'tf' => 'fr',
      'tg' => 'fr',
      'th' => 'th',
      'tj' => 'tg,ru',
      'tk' => 'tkl,en,sm',
      'tl' => 'pt,tet',
      'tm' => 'tk',
      'tn' => 'ar',
      'to' => 'en',
      'tr' => 'tr',
      'tt' => 'en',
      'tv' => 'en',
      'tw' => 'zh',
      'tz' => 'sw,en',
      'ua' => 'uk',
      'ug' => 'en,sw',
      'um' => 'en',
      'us' => 'en,es',
      'uy' => 'es',
      'uz' => 'uz,kaa',
      'va' => 'it',
      'vc' => 'en',
      've' => 'es',
      'vg' => 'en',
      'vi' => 'en',
      'vn' => 'vi',
      'vu' => 'bi,en,fr',
      'wf' => 'fr',
      'ws' => 'sm,en',
      'ye' => 'ar',
      'yt' => 'fr',
      'za' => 'zu,xh,af,st,tn,en',
      'zm' => 'en',
      'zw' => 'en,sn,nd'
    );
    #----
    $code = strtolower($code);
    if ($code == 'eu') {
      return 'en_GB';
    }
    elseif ($code == 'ap') { # Asia Pacific
      return 'en_US';
    }
    elseif ($code == 'cs') {
       return 'sr_RS';
    }
    #----
    if ($code == 'uk') {
      $code = 'gb';
    }
    if (array_key_exists($code, $arr)) {
      if (strpos($arr[$code], ',') !== false) {
        $new = explode(',', $arr[$code]);
        $loc = array();
        foreach ($new as $key => $val) {
          $loc[] = $val.'_'.strtoupper($code);
        }
        return implode(',', $loc); # string; comma-separated values 'en_GB,ga_GB,cy_GB,gd_GB,kw_GB'
      }
      else {
        return $arr[$code].'_'.strtoupper($code); # string 'en_US'
      }
    }
    return 'en_US';
  }
1100444
private function prepareName($languageCode) {
        foreach ($this->container->getParameter('chill_main.available_languages') as $lang) {
            $names[$lang] = Intl::getLanguageBundle()->getLanguageName($languageCode);
        }
        
        return $names;
    }
548529
public function getReturnCodeName($returnCode)
    {
        if (isset(self::$qosLevels[$returnCode])) {
            return self::$qosLevels[$returnCode][0];
        }

        return 'Unknown '.$returnCode;
    }
588947
protected function getCountryIdByIso2Code($countryIso2Code): int
    {
        if (!isset(static::$countryIdsCache[$countryIso2Code])) {
            static::$countryIdsCache[$countryIso2Code] = SpyCountryQuery::create()
                ->findOneByIso2Code($countryIso2Code)
                ->getIdCountry();
        }

        return static::$countryIdsCache[$countryIso2Code];
    }
1149913
public static function country($code)
	{
		$adapter  = new \Geocoder\HttpAdapter\CurlHttpAdapter();

		$p = array();

		// Get a list of providers
		if ($providers = \Event::trigger('geocode.onGeocodeProvider', array('geocode.country', $adapter)))
		{
			foreach ($providers as $provider)
			{
				if ($provider)
				{
					$p[] = $provider;
				}
			}
		}

		if (!count($p))
		{
			return '';
		}

		// Instantiate the Geocoder service and pass it the list of providers
		$geocoder = new \Geocoder\Geocoder();
		$geocoder->registerProvider(new \Geocoder\Provider\ChainProvider($p));

		// Try to get some data...
		$geocoder->setResultFactory(new Result\CountryResultFactory());

		$country = $code;
		if ($data = $geocoder->geocode($code))
		{
			if (is_array($data))
			{
				$country = $data[0]->getCountry();
			}
			else
			{
				$country = $data->getCountry();
			}
		}
		return $country;
	}
393408
public function getStandardRate($countryCode)
    {
        $country = $this->getCountry($countryCode);
        if (!is_null($country)) {
            return $country->getStandardRate();
        }

        return null;
    }
164280
public static function getName(CountryCode $code)
    {
        $codeValue = $code->toNative();
        $name      = self::$names[$codeValue];

        return new StringLiteral($name);
    }
838226
private function removeCountryCode($code)
    {

        // Get the seven first digits
        $first7 = substr($code, 0, 7);

        // Select the right set of rules according to the product code
        foreach ($this->getRanges()->getPrefixes() as $p) {
            if ($p['Prefix'] == $this->getProduct()) {
                $rules = $p['Rules']['Rule'];
                break;
            }
        }

        // If product code was not found, cannot proceed
        if (empty($rules)) {
            return null;
        }

        // Select the right rule
        foreach ($rules as $r) {
            $ra = explode('-', $r['Range']);
            if ($first7 >= $ra[0] && $first7 <= $ra[1]) {
                $length = $r['Length'];
                break;
            }
        }

        // Country code is invalid
        if ($length === "0") {
            $this->setValid(false);
            $this->addError(self::ERROR_INVALID_COUNTRY_CODE);
            return $code;
        }

        $this->setCountry(substr($code, 0, $length));
        $code = substr($code, $length);

        return $code;
    }
733192
public function get($countryCode)
    {
        if (strlen($countryCode) !== 2) {
            throw new \InvalidArgumentException('Please provide a 2 character country code.');
        }

        $countryCode = strtoupper($countryCode);

        if (array_key_exists($countryCode, $this->aliases)) {
            $countryCode = $this->aliases[$countryCode];
        }

        return implode('', array_map([$this, 'toUnicode'], str_split($countryCode)));
    }