Skip to content

Commit

Permalink
Language drop-down menu now automatically generated
Browse files Browse the repository at this point in the history
  • Loading branch information
corbindavenport committed Nov 25, 2017
1 parent 1cf2c68 commit 49caf98
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 67 deletions.
21 changes: 15 additions & 6 deletions js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,22 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
*/

// List of Wikipedia's supported language in an array, for the auto-detect functionality
// List of Wikipedia's supported language in an array
var langArray= ["ar","az","bg","nan","be","ca","cs","da","de","et","el","en","simple","es","eo","eu","fa","fr","gl","ko","hy","hi","hr","id","it","he","ka","la","lt","hu","ms","min","nl","ja","no","nn","ce","uz","pl","pt","kk","ro","ru","ceb","sk","sl","sr","sh","fi","sv","ta","th","tr","uk","ur","vi","vo","war","zh"];
var detailArray = ["العربية","Azərbaycanca","Български","Bân-lâm-gú / Hō-ló-oē","Беларуская (Акадэмічная)","Català","Čeština","Dansk","Deutsch","Eesti","Ελληνικά","English","Simple English","Español","Esperanto","Euskara","فارسی","Français","Galego","한국어","Հայերեն","हिन्दी","Hrvatski","Bahasa Indonesia","Italiano","עברית","ქართული","Latina","Lietuvių","Magyar","Bahasa Melayu","Bahaso Minangkabau","Nederlands","日本語","Norsk (Bokmål)","Norsk (Nynorsk)","Нохчийн","Oʻzbekcha / Ўзбекча","Polski","Português","Қазақша / Qazaqşa / قازاقشا","Română","Русский","Sinugboanong Binisaya","Slovenčina","Slovenščina","Српски / Srpski","Srpskohrvatski / Српскохрватски","Suomi","Svenska","தமிழ்","ภาษาไทย","Türkçe","Українська","اردو","Tiếng Việt","Volapük","Winaray","中文"];

// Load settings
$(window).on('load', function() {
// Populate languages menu
langArray.forEach(function callback(currentValue, index, array) {
$('#language').append($('<option>', {
value: currentValue,
text: detailArray[langArray.indexOf(currentValue)]
}));
});
// Remove loading option
$("#language option[value='loading'").remove();
// Set to current language
$("#language").val(localStorage["language"]);
if (localStorage.getItem("protocol") === "https://") {
$("input[name='protocol']").prop("checked", true);
Expand All @@ -35,7 +45,6 @@ $(document).on('click', ".reset-language", function() {
localStorage["language"] = lang;
localStorage["full-language"] = detailArray[langArray.indexOf(lang)];
} else {
// Set it to English as default
alert("Sorry, Wikipedia Search could not auto-detect your system language.")
}
});
Expand All @@ -46,9 +55,9 @@ $(document).on('change', "input,select", function() {
localStorage["language"] = $("#language").val();
localStorage["full-language"] = detailArray[langArray.indexOf($("#language").val())];
if ($("input[name='protocol']").is(":checked")) {
localStorage["protocol"] = "https://";
} else {
localStorage["protocol"] = "http://";
}
localStorage["protocol"] = "https://";
} else {
localStorage["protocol"] = "http://";
}
localStorage.setItem("shortcut", $("input[name='shortcut']").is(":checked"));
});
62 changes: 1 addition & 61 deletions settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,67 +37,7 @@ <h3>Language</h3>
<div class="row">
<div class="col-sm-8">
<select id="language" name="language" class="form-control form-control-lg">
<!-- 100,000+ content pages, sorted by romanization -->
<!-- 100,000+ content pages, sorted by romanization -->
<option value="ar" lang="ar">العربية</option><!-- Al-ʿArabīyah -->
<option value="az" lang="az">Azərbaycanca</option>
<option value="bg" lang="bg">Български</option><!-- Bǎlgarski -->
<option value="nan" lang="nan">Bân-lâm-gú / Hō-ló-oē</option>
<option value="be" lang="be">Беларуская (Акадэмічная)</option><!-- Belaruskaya (Akademichnaya) -->
<option value="ca" lang="ca">Català</option>
<option value="cs" lang="cs">Čeština</option>
<option value="da" lang="da">Dansk</option>
<option value="de" lang="de">Deutsch</option>
<option value="et" lang="et">Eesti</option>
<option value="el" lang="el">Ελληνικά</option><!-- Ellīniká -->
<option value="en" lang="en">English</option><!-- English -->
<option value="es" lang="es">Español</option>
<option value="eo" lang="eo">Esperanto</option>
<option value="eu" lang="eu">Euskara</option>
<option value="fa" lang="fa">فارسی</option><!-- Fārsi -->
<option value="fr" lang="fr">Français</option>
<option value="gl" lang="gl">Galego</option>
<option value="ko" lang="ko">한국어</option><!-- Hangugeo -->
<option value="hy" lang="hy">Հայերեն</option><!-- Hayeren -->
<option value="hi" lang="hi">हिन्दी</option><!-- Hindī -->
<option value="hr" lang="hr">Hrvatski</option>
<option value="id" lang="id">Bahasa Indonesia</option>
<option value="it" lang="it">Italiano</option>
<option value="he" lang="he">עברית</option><!-- ʿIvrit -->
<option value="ka" lang="ka">ქართული</option><!-- Kartuli -->
<option value="la" lang="la">Latina</option>
<option value="lt" lang="lt">Lietuvių</option>
<option value="hu" lang="hu">Magyar</option>
<option value="ms" lang="ms">Bahasa Melayu</option>
<option value="min" lang="min">Bahaso Minangkabau</option>
<option value="nl" lang="nl">Nederlands</option>
<option value="ja" lang="ja">日本語</option><!-- Nihongo -->
<option value="no" lang="nb">Norsk (Bokmål)</option>
<option value="nn" lang="nn">Norsk (Nynorsk)</option>
<option value="ce" lang="ce">Нохчийн</option><!-- Noxçiyn -->
<option value="uz" lang="uz">Oʻzbekcha / Ўзбекча</option>
<option value="pl" lang="pl">Polski</option>
<option value="pt" lang="pt">Português</option>
<option value="kk" lang="kk">Қазақша / Qazaqşa / قازاقشا</option>
<option value="ro" lang="ro">Română</option>
<option value="ru" lang="ru">Русский</option><!-- Russkiy -->
<option value="simple" lang="en">Simple English</option>
<option value="ceb" lang="ceb">Sinugboanong Binisaya</option>
<option value="sk" lang="sk">Slovenčina</option>
<option value="sl" lang="sl">Slovenščina</option>
<option value="sr" lang="sr">Српски / Srpski</option>
<option value="sh" lang="sh">Srpskohrvatski / Српскохрватски</option>
<option value="fi" lang="fi">Suomi</option>
<option value="sv" lang="sv">Svenska</option>
<option value="ta" lang="ta">தமிழ்</option><!-- Tamiḻ -->
<option value="th" lang="th">ภาษาไทย</option><!-- Phasa Thai -->
<option value="tr" lang="tr">Türkçe</option><!-- Turkce -->
<option value="uk" lang="uk">Українська</option><!-- Ukrayins’ka -->
<option value="ur" lang="ur">اردو</option><!-- Urdu -->
<option value="vi" lang="vi">Tiếng Việt</option>
<option value="vo" lang="vo">Volapük</option>
<option value="war" lang="war">Winaray</option>
<option value="zh" lang="zh">中文</option><!-- Zhōngwén -->
<option value="loading" disabled selected>Loading languages...</option>
</select>
</div>
<div class="col-sm-4">
Expand Down

0 comments on commit 49caf98

Please sign in to comment.