Jdrewniak has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/383337 )

Change subject: Exposing available translations in JS variable
......................................................................

Exposing available translations in JS variable

Bug: T171647
Change-Id: I01061c7eee382d159918e2f3aea6d9deef7e75b0
---
M dev/wikipedia.org/controller.js
M dev/wikipedia.org/index.handlebars
2 files changed, 15 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikimedia/portals 
refs/changes/37/383337/1

diff --git a/dev/wikipedia.org/controller.js b/dev/wikipedia.org/controller.js
index c403fd2..b624a51 100644
--- a/dev/wikipedia.org/controller.js
+++ b/dev/wikipedia.org/controller.js
@@ -103,6 +103,18 @@
        createTranslationFiles( translationPath, siteStats, cachebuster );
 }
 
+function availableLanguages( siteStats ) {
+       var langs = [], lang;
+       for ( lang in siteStats ) {
+               if ( siteStats[ lang ].sublinks ) {
+                       siteStats[ lang ].sublinks.forEach( function( lang ) { 
langs.push( lang.code ); } );
+               } else {
+                       langs.push( lang );
+               }
+       }
+       return langs;
+}
+
 Controller = {
        top10views: stats.getTopFormatted( 'wiki', 'views', 10 ),
        top1000000Articles: stats.getRangeFormatted( 'wiki', 'numPages', 
1000000 ),
@@ -116,7 +128,8 @@
        rtlLanguages: rtlLanguages,
        // The only "advantage" to do this instead of JSON.stringify is to get 
single quotes.
        rtlLanguagesStringified: '[\'' + rtlLanguages.join( '\',\'' ) + '\']',
-       translationChecksum: cachebuster
+       translationChecksum: cachebuster,
+       availableLanguages: JSON.stringify( availableLanguages( siteStats ) )
 };
 
 module.exports = Controller;
diff --git a/dev/wikipedia.org/index.handlebars 
b/dev/wikipedia.org/index.handlebars
index fbeb485..922ff7f 100644
--- a/dev/wikipedia.org/index.handlebars
+++ b/dev/wikipedia.org/index.handlebars
@@ -59,6 +59,7 @@
 <script>
     var rtlLangs = {{{rtlLanguagesStringified}}},
     translationsHash = '{{translationChecksum}}',
+    availableLanguages = {{{ availableLanguages }}},
     /*
      This object is used by l10n scripts (page-localized.js, 
topten-localized.js)
      to reveal the page content after l10n json is loaded.

-- 
To view, visit https://gerrit.wikimedia.org/r/383337
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I01061c7eee382d159918e2f3aea6d9deef7e75b0
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/portals
Gerrit-Branch: master
Gerrit-Owner: Jdrewniak <jdrewn...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to