Skip to content
Extraits de code Groupes Projets
Valider 3cb7169c rédigé par Stefan Giehl's avatar Stefan Giehl Validation de GitHub
Parcourir les fichiers

Show Tibet as part of China on map (#11930)

* Revert "free tibet!"

This reverts commit 4e47c8ab.

* Remove unneeded translations

* adjust API

* fix tests

* update screenshots

* update tests files

* update screenshot

* Do not change detected location

* update tests

* Fix continent detection for old records

* submodule update

* update screenshots

* Cleanup

* use group by filters only if needed

* make filter work for datatable maps
parent 571d96e9
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 61 ajouts et 60 suppressions
......@@ -1026,6 +1026,10 @@ class Common
$countryList = $dataProvider->getCountryList();
if ($country == 'ti') {
$country = 'cn';
}
return isset($countryList[$country]) ? $countryList[$country] : 'unk';
}
......
......@@ -237,7 +237,6 @@ return array(
'tf' => 'ant',
'tg' => 'afr',
'th' => 'asi',
'ti' => 'asi', // Tibet (no iso 3166 code)
'tj' => 'asi',
'tk' => 'oce',
'tl' => 'asi',
......
......@@ -54,7 +54,7 @@ return array(
'sr' => 'rs', // Serbian => Serbia
'sv' => 'se', // Swedish => Sweden
'th' => 'th', // Thai => Thailand
'bo' => 'ti', // Tibetan => Tibet
'bo' => 'cn', // Tibetan => China
'tr' => 'tr', // Turkish => Turkey
'uk' => 'ua', // Ukrainian => Ukraine
);
......@@ -234,7 +234,6 @@ class CountryCallingCodes
// 'tf' => 'MISSING CODE',
'tg' => '228',
'th' => '66',
// 'ti' => 'MISSING CODE',
'tj' => '992',
'tk' => '690',
'tl' => '670',
......
Subproject commit 0c4e30d95c1a36bf540df5e5d67a3161053c4909
Subproject commit 3d383b913471fae94ca30a5f413454c944e16579
......@@ -32,6 +32,26 @@ class API extends \Piwik\Plugin\API
{
$dataTable = $this->getDataTable(Archiver::COUNTRY_RECORD_NAME, $idSite, $period, $date, $segment);
$dataTables = [$dataTable];
if ($dataTable instanceof DataTable\Map) {
$dataTables = $dataTable->getDataTables();
}
foreach ($dataTables as $dt) {
if ($dt->getRowFromLabel('ti')) {
$dt->filter('GroupBy', array(
'label',
function ($label) {
if ($label == 'ti') {
return 'cn';
}
return $label;
}
));
}
}
// apply filter on the whole datatable in order the inline search to work (searches are done on "beautiful" label)
$dataTable->filter('AddSegmentValue');
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'code'));
......@@ -75,6 +95,27 @@ class API extends \Piwik\Plugin\API
$separator = Archiver::LOCATION_SEPARATOR;
$unk = Visit::UNKNOWN_CODE;
// show visits tracked as Tibet as region of China
$dataTables = [$dataTable];
if ($dataTable instanceof DataTable\Map) {
$dataTables = $dataTable->getDataTables();
}
foreach ($dataTables as $dt) {
if ($dt->getRowFromLabel('1|ti')) {
$dt->filter('GroupBy', array(
'label',
function ($label) {
if ($label == '1|ti') {
return 'cn';
}
return $label;
}
));
}
}
// split the label and put the elements into the 'region' and 'country' metadata fields
$dataTable->filter('ColumnCallbackAddMetadata',
array('label', 'region', __NAMESPACE__ . '\getElementFromStringArray', array($separator, 0, $unk)));
......
......@@ -54,7 +54,6 @@ abstract class GeoIp extends LocationProvider
*/
public function completeLocationResult(&$location)
{
$this->fixupLocation($location);
parent::completeLocationResult($location);
// set region name if region code is set
......@@ -68,21 +67,6 @@ abstract class GeoIp extends LocationProvider
}
}
/**
* Fix up data to work with our SVG maps which include 'Tib' boundaries
*/
protected function fixupLocation(&$location)
{
if (!empty($location[self::REGION_CODE_KEY])
&& $location[self::REGION_CODE_KEY] == '14'
&& !empty($location[self::COUNTRY_CODE_KEY])
&& strtoupper($location[self::COUNTRY_CODE_KEY]) == 'CN'
) {
$location[self::COUNTRY_CODE_KEY] = 'ti';
$location[self::REGION_CODE_KEY] = '1';
}
}
/**
* Returns true if this provider has been setup correctly, the error message if
* otherwise.
......@@ -155,6 +139,12 @@ abstract class GeoIp extends LocationProvider
$countryCode = strtoupper($countryCode);
$regionCode = strtoupper($regionCode);
// ensure tibet is shown as region of china
if ($countryCode == 'TI' && $regionCode == '1') {
$regionCode = '14';
$countryCode = 'CN';
}
if (isset($regionNames[$countryCode][$regionCode])) {
return $regionNames[$countryCode][$regionCode];
} else {
......
......@@ -22,6 +22,10 @@ use Piwik\Tracker\Visit;
*/
function getFlagFromCode($code)
{
if (strtolower($code) == 'ti') {
$code = 'cn';
}
$pathInPiwik = 'plugins/Morpheus/icons/dist/flags/%s.png';
$pathWithCode = sprintf($pathInPiwik, $code);
$absolutePath = PIWIK_INCLUDE_PATH . '/' . $pathWithCode;
......@@ -57,6 +61,10 @@ function countryTranslate($label)
return Piwik::translate('General_Unknown');
}
if (strtolower($label) == 'ti') {
$label = 'cn';
}
// Try to get name from Intl plugin
$key = 'Intl_Country_' . strtoupper($label);
$country = Piwik::translate($key);
......
......@@ -16,7 +16,6 @@
"country_a2": "Satelitní poskytovatel",
"country_cat": "Katalánsky mluvící země",
"country_o1": "ostatní země",
"country_ti": "Tibet",
"CurrentLocationIntro": "Podle tohoto poskytovatele je vaše aktuální umístění",
"DefaultLocationProviderDesc1": "Výchozí poskytovatel umístění odhaduje zemi návštěvníka na základě použitého jazyka.",
"DefaultLocationProviderDesc2": "To není příliš přesné, proto doporučujeme %1$sinstalovat a používat %2$sGEOIP%3$s.%4$s",
......@@ -94,8 +93,4 @@
"UpdaterWasLastRun": "Aktualizátor byl naposledy spuštěn v %s.",
"UpdaterWillRunNext": "Další spuštění je naplánováno na %s.",
"WidgetLocation": "Umístění návštěvníka"
},
"Intl": {
"Country_TI": "Tibet"
}
}
\ No newline at end of file
......@@ -16,7 +16,6 @@
"country_a2": "Satellit udbyder",
"country_cat": "Catalansk-talende samfund",
"country_o1": "Andet land",
"country_ti": "Tibet",
"CurrentLocationIntro": "I følge denne tjeneste er din aktuelle lokation",
"DefaultLocationProviderDesc1": "Standardlokationstjenesten gætter en besøgendes land baseret på det sprog de bruger.",
"DefaultLocationProviderDesc2": "Dette er ikke særlig nøjagtigt, så %1$svi anbefaler at du installerer og bruger %2$sGeoIP%3$s.%4$s",
......@@ -94,8 +93,5 @@
"UpdaterWasLastRun": "Opdateringen blev sidst blev kørt den %s.",
"UpdaterWillRunNext": "Næste planlagte kørsel %s.",
"WidgetLocation": "Besøgendes lokation"
},
"Intl": {
"Country_TI": "Tibet"
}
}
\ No newline at end of file
......@@ -16,7 +16,6 @@
"country_a2": "Satelliten-Anbieter",
"country_cat": "Katalanisch sprechende Gemeinden",
"country_o1": "Anderes Land",
"country_ti": "Tibet",
"CurrentLocationIntro": "Gemäß diesem Provider ist Ihr derzeitiger Standort",
"DefaultLocationProviderDesc1": "Die voreingestellte Standorterkennung versucht das Herkunftsland des Besuchers anhand dessen verwendeter Sprache zu erkennen.",
"DefaultLocationProviderDesc2": "Dies ist nicht sehr genau, daher %1$swird empfohlen %2$sGeoIP%3$s zu installieren und zu nutzen.%4$s",
......@@ -94,8 +93,5 @@
"UpdaterWasLastRun": "Die Aktualisierung wurde zuletzt ausgeführt am %s.",
"UpdaterWillRunNext": "Nächste Ausführung geplant für %s.",
"WidgetLocation": "Besucherstandort"
},
"Intl": {
"Country_TI": "Tibet"
}
}
\ No newline at end of file
......@@ -16,7 +16,6 @@
"country_a2": "Πάροχος δορυφόρου",
"country_cat": "Καταλανικόφωνες κοινότητες",
"country_o1": "Άλλη Χώρα",
"country_ti": "Θιβέτ",
"CurrentLocationIntro": "Σύμφωνα με τον πάροχο, η τρέχουσα τοποθεσία σας είναι",
"DefaultLocationProviderDesc1": "Ο προεπιλεγμένος πάροχος θέσης εικάζει τη χώρα του επισκέπτη με βάση τη γλώσσα που χρησιμοποιεί.",
"DefaultLocationProviderDesc2": "Αυτό δεν είναι πολύ ακριβές, έτσι %1$sπροτείνουμε την εγκατάσταση και τη χρήση %2$sGeoIP%3$s.%4$s",
......@@ -94,8 +93,5 @@
"UpdaterWasLastRun": "Το πρόγραμμα ενημέρωσης εκτελέστηκε τελευταία στις %s.",
"UpdaterWillRunNext": "Είναι προγραμματισμένο για εκτέλεση στις %s.",
"WidgetLocation": "Τοποθεσία Επισκέπτη"
},
"Intl": {
"Country_TI": "Θιβέτ"
}
}
\ No newline at end of file
......@@ -16,7 +16,6 @@
"country_a2": "Satellite Provider",
"country_cat": "Catalan-speaking communities",
"country_o1": "Other Country",
"country_ti": "Tibet",
"CurrentLocationIntro": "According to this provider, your current location is",
"DefaultLocationProviderDesc1": "The default location provider guesses a visitor's country based on the language they use.",
"DefaultLocationProviderDesc2": "This is not very accurate, so %1$swe recommend installing and using %2$sGeoIP%3$s.%4$s",
......@@ -94,8 +93,5 @@
"UpdaterWasLastRun": "The updater was last run on %s.",
"UpdaterWillRunNext": "It is next scheduled to run on %s.",
"WidgetLocation": "Visitor Location"
},
"Intl": {
"Country_TI": "Tibet"
}
}
\ No newline at end of file
......@@ -16,7 +16,6 @@
"country_a2": "Proveedor Satelital",
"country_cat": "Comunidades de habla catalana",
"country_o1": "Otro país",
"country_ti": "Tibet",
"CurrentLocationIntro": "De acuerdo a este proveedor, su actual ubicación es",
"DefaultLocationProviderDesc1": "La ubicación predeterminada del proveedor asume que el país del visitante es por el lenguaje que el mismo utiliza.",
"DefaultLocationProviderDesc2": "No es muy preciso, por lo tanto %1$srecomendamos instalar y utilizar %2$sGeoIP%3$s.%4$s",
......@@ -94,8 +93,5 @@
"UpdaterWasLastRun": "El actualizador se ejecutó por última vez en %s.",
"UpdaterWillRunNext": "Está programada la ejecución para el %s.",
"WidgetLocation": "Ubicación del visitante"
},
"Intl": {
"Country_TI": "Tíbet"
}
}
\ No newline at end of file
......@@ -8,7 +8,6 @@
"country_a2": "Satelliidi pakkuja",
"country_cat": "Katalaani kommuunid",
"country_o1": "Muu riik",
"country_ti": "Tiibet",
"CurrentLocationIntro": "Antud pakkuja andmete alusel on sinu praegune asukoht",
"DistinctCountries": "%s eri riigist",
"DownloadingDb": "Laen alla %s",
......@@ -31,8 +30,5 @@
"SubmenuLocations": "Asukohad",
"UpdaterWasLastRun": "Uuendaja käivitus viimati %s.",
"WidgetLocation": "Külastajate asukohad"
},
"Intl": {
"Country_TI": "Tiibet"
}
}
\ No newline at end of file
......@@ -16,7 +16,6 @@
"country_a2": "Satelliittiyhteys",
"country_cat": "Katalaania puhuvat alueet",
"country_o1": "Muu maa",
"country_ti": "Tiibet",
"CurrentLocationIntro": "Tämän toteutuksen mukaan nykyinen sijaintisi on",
"DefaultLocationProviderDesc1": "Oletustoteutus arvaa käyttäjien maan kielen perusteella.",
"DefaultLocationProviderDesc2": "Tämä ei ole erityisen tarkkaa, joten %1$ssuosittelemme asentamaan ja käyttämään %2$sGeoIp:tä%3$s.%4$s",
......
......@@ -16,7 +16,6 @@
"country_a2": "Fournisseur satellite",
"country_cat": "Communautés de langue Catalane",
"country_o1": "Autre pays",
"country_ti": "Tibet",
"CurrentLocationIntro": "D'après ce fournisseur, votre emplacement actuel est",
"DefaultLocationProviderDesc1": "Le fournisseur de localisation par défaut devine le pays d'un visiteur en se basant sur le langage de son navigateur.",
"DefaultLocationProviderDesc2": "Ce n'est pas très précis, nous recommandons donc %1$sd'installer et d'utiliser %2$sGeoIP%3$s.%4$s",
......@@ -94,8 +93,5 @@
"UpdaterWasLastRun": "La dernière mise à jour a été effectuée le %s.",
"UpdaterWillRunNext": "Est planifié pour s'exécuter le %s.",
"WidgetLocation": "Emplacement du visiteur"
},
"Intl": {
"Country_TI": "Tibet"
}
}
\ No newline at end of file
......@@ -3,7 +3,6 @@
"Continent": "Continente",
"Country": "País",
"country_o1": "Outro país",
"country_ti": "Tíbet",
"DistinctCountries": "%s continentes distintos",
"DownloadingDb": "A descargar %s",
"DownloadNewDatabasesEvery": "Actualizar as bases de datos cada",
......
......@@ -15,7 +15,6 @@
"country_a2": "सैटेलाइट प्रदाता",
"country_cat": "कैटलन भाषी समुदायों",
"country_o1": "अन्य देश",
"country_ti": "तिब्बत",
"CurrentLocationIntro": "इस प्रदाता के अनुसार, आपका वर्तमान स्थान है",
"DefaultLocationProviderDesc1": "एक आगंतुक का देश डिफ़ॉल्ट स्थान प्रदाता के अनुमान का इस्तेमाल वे भाषा के आधार पर करते है.",
"DefaultLocationProviderDesc2": "यह बहुत सही नहीं है, तो %1$sहम स्थापित करने और %2$sGeoIP%3$s का उपयोग करना चाहिये.%4$s",
......
......@@ -16,7 +16,6 @@
"country_a2": "Penyedia Satelit",
"country_cat": "Masyarakat berbahasa Katalan",
"country_o1": "Negara Lain",
"country_ti": "Tibet",
"CurrentLocationIntro": "Berdasar penyedia ini, lokasi Anda adalah",
"DefaultLocationProviderDesc1": "Lokasi penyedia asali menebak negara pengunjung dari bahasa yang digunakan.",
"DefaultLocationProviderDesc2": "Ini sangat tidak teliti, serta %1$skami menyarankan memasang dan menggunakan %2$sGeoIP%3$s.%4$s",
......@@ -87,8 +86,5 @@
"UpdaterHasNotBeenRun": "Pembaruan belum pernah berjalan.",
"UpdaterWasLastRun": "Pembaruan terakhir berjalan dalam %s.",
"WidgetLocation": "Lokasi Pengunjung"
},
"Intl": {
"Country_TI": "Tibet"
}
}
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter