Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/UserCountry/API.php')
-rw-r--r--plugins/UserCountry/API.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/plugins/UserCountry/API.php b/plugins/UserCountry/API.php
index f36e7e70b8..176030ec31 100644
--- a/plugins/UserCountry/API.php
+++ b/plugins/UserCountry/API.php
@@ -10,6 +10,7 @@ namespace Piwik\Plugins\UserCountry;
use Exception;
use Piwik\Archive;
+use Piwik\Container\StaticContainer;
use Piwik\DataTable;
use Piwik\Metrics;
use Piwik\Piwik;
@@ -165,6 +166,24 @@ class API extends \Piwik\Plugin\API
}
/**
+ * Returns a simple mapping from country code to country name
+ *
+ * @return \string[]
+ */
+ 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;
+ }
+
+ /**
* Uses a location provider to find/guess the location of an IP address.
*
* See LocationProvider::getLocation to see the details