From c19c0b4db7d66fd8192adda8fda45a8d69ca0b5f Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Sat, 13 Oct 2012 10:50:03 +0530 Subject: [PATCH] Fix Bug 40714 - ULS geoclient needs proper interface Change-Id: Id8d7356ec75e8652c75927736a60b916dd069c28 --- UniversalLanguageSelector.php | 4 ++-- resources/js/ext.uls.geoclient.js | 4 ++++ resources/js/ext.uls.init.js | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/UniversalLanguageSelector.php b/UniversalLanguageSelector.php index b9f9c060..a3bc1873 100644 --- a/UniversalLanguageSelector.php +++ b/UniversalLanguageSelector.php @@ -49,8 +49,8 @@ $wgExtensionCredits['other'][] = array( * ULS can use geolocation services to suggest languages based on the * country the user is vising from. Setting this to false will prevent * builtin geolocation from being used. You can provide your own geolocation - * by setting window.GEO to object which has key country_code. This is what - * Wikipedia does. + * by setting window.GEO to object which has key 'country_code' or 'country'. + * This is what Wikipedia does. * * The service should return jsonp that uses the supplied callback parameter. */ diff --git a/resources/js/ext.uls.geoclient.js b/resources/js/ext.uls.geoclient.js index 65a06cfe..7d66530e 100644 --- a/resources/js/ext.uls.geoclient.js +++ b/resources/js/ext.uls.geoclient.js @@ -25,6 +25,10 @@ window.GEO = data; }; + mw.uls.getCountryCode = function () { + return window.GEO.country || window.GEO.country_code; + }; + var settings = { cache: true, dataType: "jsonp", diff --git a/resources/js/ext.uls.init.js b/resources/js/ext.uls.init.js index e1ff9247..fa2b0ae6 100644 --- a/resources/js/ext.uls.init.js +++ b/resources/js/ext.uls.init.js @@ -73,7 +73,7 @@ .concat( mw.uls.getAcceptLanguageList() ); if ( window.GEO ) { - list = list.concat( $.uls.data.getLanguagesInTerritory( window.GEO.country_code ) ); + list = list.concat( $.uls.data.getLanguagesInTerritory( mw.uls.getCountryCode() ) ); } $.each( list, function ( i, v ) {