/** * to benefit of [[:Template:Multilingual description]] * * Implements language selection for multilingual elements * * In certain environments, it's not feasible to neatly box away each * different language into its own section of the site. By marking elements * multilingual, you can emulate this behavior by only displaying the * message in the user's language. This reduces the "Tower of Babel" effect. * * @author Edward Z. Yang (Ambush Commander), Rewritten by DieBuche */ /* Configuration: */ // in your monobook.js, set ls_enable = false to stop the javascript // the cookie name we use to stash the info. mediaWiki.loader.using('jquery.cookie', function() { var multilingual = { cookie: 'commonswiki_language_js', // link to the language select page helpUrl: 'http://meta.wikimedia.org/wiki/Meta:Language_select', // strings that are part of the widgets stringHelp: { 'be-tarask' : 'Выбар мовы', 'be-x-old' : 'Выбар мовы', 'cs': 'Výběr jazyka:', 'da': 'Vælg sprog:', 'de': 'Sprachauswahl:', 'en': 'Language select:', 'eo': 'Lingvoelekto:', 'fr': 'Selecteur de langue:', 'hu': 'Nyelvválasztás:', 'ko': '언어 선택:', 'mk': 'Јазик:', 'ml': 'ഭാഷ തിരഞ്ഞെടുക്കുക:', 'nds': 'Spraakutwahl:', 'nl': 'Taal:', 'pl': 'Wybierz język:', 'pt': 'Seleção do idioma:', 'pt-br': 'Seleção do idioma:', 'ru': 'Выбор языка:', 'sv': 'Välj språk:' }, stringSelect: { 'be-tarask' : 'Выбраць', 'be-x-old' : 'Выбраць', 'cs': 'Vybrat', 'da': 'Vælg', 'de': 'Auswahl', 'en': 'Select', 'eo': 'Elekti', 'fr': 'Seulement ce langage', 'hu': 'Választás', 'ko': '선택', 'mk': 'Одбери', 'ml': 'തിരഞ്ഞെടുക്കുക', 'nds': 'Utwählen', 'nl': 'Selecteer', 'pl': 'Wybierz', 'pt': 'Selecionar', 'pt-br': 'Selecionar', 'ru': 'Выбрать', 'sv': 'Välj' }, stringShowAll: { 'be-tarask' : 'Паказаць усе', 'be-x-old' : 'Паказаць усе', 'cs': 'Zobrazit všechny', 'da': 'Vis alle', 'de': 'Alle anzeigen', 'en': 'Show all', 'eo': 'ĉiuj', 'fr': 'Tous les langages', 'hu': 'Mutasd mind', 'ko': '모두 보기', 'mk': 'Сите', 'ml': 'എല്ലാം', 'nds': 'All wiesen', 'nl': 'Toon alles', 'pl': 'Pokaż wszystkie', 'pt': 'Mostrar todos', 'pt-br': 'Mostrar todos', 'ru': 'Показать все', 'sv': 'Visa alla' }, // autodetects a browser language getBrowserLanguage: function () { return navigator.userLanguage || navigator.language || navigator.browserLanguage; }, // sets a new language to the cookie setCookieLanguage: function (language) { jQuery.cookie(this.cookie, escape(language), { expires: 100, path: '/' }); }, // deletes the cookie deleteCookieLanguage: function (language) { jQuery.cookie(this.cookie, null, { path: '/' }); }, // grabs the ISO 639 language code based // on either the browser or a supplied cookie getLanguage: function () { var language = ''; // Priority: // 1. Cookie // 2. wgUserLanguage global variable // 3. Browser autodetection // grab according to cookie language = jQuery.cookie(this.cookie); // grab according to wgUserLanguage if user is logged in if (!language && window.wgUserLanguage && wgUserGroups !== null) { language = wgUserLanguage; } // grab according to browser if none defined if (!language) language = this.getBrowserLanguage(); // inflexible: can't accept multiple languages // remove dialect/region code, leaving only the ISO 639 code // language = language.replace(/(-.*)+/, ''); return language; }, // build widget for changing the language cookie buildWidget: function (language) { this.jQuerycontainer = jQuery('
'); // link to language select description page this.jQuerycontainer.html('' + this.stringHelpText + ' '); this.jQueryselect = jQuery('