diff options
Diffstat (limited to 'core/Intl')
-rw-r--r-- | core/Intl/Data/Provider/LanguageDataProvider.php | 45 | ||||
-rw-r--r-- | core/Intl/Data/Provider/RegionDataProvider.php | 49 |
2 files changed, 94 insertions, 0 deletions
diff --git a/core/Intl/Data/Provider/LanguageDataProvider.php b/core/Intl/Data/Provider/LanguageDataProvider.php new file mode 100644 index 0000000000..8369d8b1a7 --- /dev/null +++ b/core/Intl/Data/Provider/LanguageDataProvider.php @@ -0,0 +1,45 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Intl\Data\Provider; + +/** + * Provides language data. + */ +class LanguageDataProvider +{ + /** + * Returns the list of valid language codes. + * + * @return string[] Array of 2 letter ISO code => language name (in english). + * E.g. `array('en' => 'English', 'ja' => 'Japanese')`. + * @api + */ + public static function getLanguageList() + { + require_once PIWIK_INCLUDE_PATH . '/core/DataFiles/Languages.php'; + + $languagesList = $GLOBALS['Piwik_LanguageList']; + return $languagesList; + } + + /** + * Returns the list of language to country mappings. + * + * @return string[] Array of 2 letter ISO language code => 2 letter ISO country code. + * E.g. `array('fr' => 'fr') // French => France`. + * @api + */ + public static function getLanguageToCountryList() + { + require_once PIWIK_INCLUDE_PATH . '/core/DataFiles/LanguageToCountry.php'; + + $languagesList = $GLOBALS['Piwik_LanguageToCountry']; + return $languagesList; + } +} diff --git a/core/Intl/Data/Provider/RegionDataProvider.php b/core/Intl/Data/Provider/RegionDataProvider.php new file mode 100644 index 0000000000..b47aa4ab9c --- /dev/null +++ b/core/Intl/Data/Provider/RegionDataProvider.php @@ -0,0 +1,49 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Intl\Data\Provider; + +/** + * Provides region related data (continents, countries, etc.). + */ +class RegionDataProvider +{ + /** + * Returns the list of continent codes. + * + * @return string[] Array of 3 letter continent codes + * @api + */ + public function getContinentList() + { + require_once PIWIK_INCLUDE_PATH . '/core/DataFiles/Countries.php'; + + return $GLOBALS['Piwik_ContinentList']; + } + + /** + * Returns the list of valid country codes. + * + * @param bool $includeInternalCodes + * @return string[] Array of 2 letter country ISO codes => 3 letter continent code + * @api + */ + public static function getCountryList($includeInternalCodes = false) + { + require_once PIWIK_INCLUDE_PATH . '/core/DataFiles/Countries.php'; + + $countriesList = $GLOBALS['Piwik_CountryList']; + $extras = $GLOBALS['Piwik_CountryList_Extras']; + + if ($includeInternalCodes) { + return array_merge($countriesList, $extras); + } + + return $countriesList; + } +} |