1//@license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-v3 2 3/** 4 * When the user changes the language via the language drop down, redirect the user to the relevant translation. 5 */ 6(function() { 7 var chooser = document.getElementById('language-chooser-select'); 8 // Fallback to English if none is selected 9 var activeLang = 'en'; 10 for (var i = 0; i < chooser.children.length; i++) { 11 if (chooser.children[i].selected) { 12 activeLang = chooser.children[i].value; 13 } 14 } 15 16 chooser.onchange = function() { 17 var lang = this.value; 18 var pageUrl = document.location.pathname; 19 20 /* 21 * If we are already on "/fr" and select "ES", we don't want to redirect to "/fr/es". 22 * The apache docs website achieves this via AliasMatch in their apache config, but that 23 * is not able to go into the .htaccess file and so makes the deployment of the site more 24 * difficult. This solves the problem in JavaScript. 25 */ 26 if (new RegExp('^/' + activeLang + '/').test(pageUrl)) { 27 pageUrl = pageUrl.substring(activeLang.length + 1); 28 } 29 30 document.location = '' + '/' + lang + pageUrl; 31 } 32})(); 33// @license-end 34
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.