Skip to content

Commit

Permalink
add dropdown with dummy onchange function
Browse files Browse the repository at this point in the history
  • Loading branch information
evemartin committed Apr 26, 2024
1 parent 1295f1f commit c6026cf
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
4 changes: 4 additions & 0 deletions game/static/game/js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,10 @@ function setMutedCookie(mute) {
}
}

function gameUpdateBlockLanguage(language_code) {
console.log(language_code);
}

$(document).ready(function () {
ocargo.game = new ocargo.Game()
ocargo.game.setup()
Expand Down
19 changes: 19 additions & 0 deletions game/templates/game/game.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@
<span>{% trans "Blockly" %}</span>
</label>
</div>

<div id="language_tab" class="tab">
<select name="language_dropdown" class="tab selectable bg--{{level.difficulty}}" id="language_dropdown" onchange="gameUpdateBlockLanguage(this.value)">
{% for language_code, language in available_language_dict.items %}
<option id="language_dropdown_{{language_code}}" value="{{language_code}}">{{language}}</option>
{% endfor %}
</select>
</div>

<div class="tab_break"></div>

<div id="python_tab" class="tab selectable {% if level.pythonEnabled %}{% else %}hidden{% endif %}">
<input type="radio" name="tabs" id="python_radio">
<label for="python_radio">
Expand Down Expand Up @@ -487,4 +498,12 @@ <h2 class="title"><img class="modal_image" src="{% static 'game/image/icons/shar
</div>
</div>

<script>
document.getElementById("language_dropdown").value = navigator.language.toLowerCase();

if (document.getElementById("language_dropdown").value == "") {
document.getElementById("language_dropdown").value = "en";
}
</script>

{% endblock %}
87 changes: 87 additions & 0 deletions game/views/language_code_conversions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
language_code_dict = {
"ab": "аҧсуа бызшәа",
"ar": "العربية",
"az": "azərbaycan",
"ba": "Башҡорт теле",
"bcc": "بلۏچی",
"be": "беларуская",
"be-tarask": "тарашкевіца",
"bg": "български",
"bn": "বাংলা",
"br": "Brezhoneg",
"ca": "Català",
"cs": "čeština",
"da": "Dansk",
"de": "Deutsch",
"diq": "Zazakî",
"dty": "डोटेली",
"el": "Ελληνικά",
"en": "English",
"en-gb": "English (UK)",
"eo": "Esperanto",
"es": "Español",
"et": "Eesti",
"eu": "Euskara",
"fa": "فارسی",
"fi": "Suomi",
"fr": "Français",
"gl": "Galego",
"gor": "Hulontalo",
"ha": "Hausa",
"he": "עברית",
"hi": "हिन्दी",
"hrx": "Hunsrik",
"hu": "Magyar",
"hy": "հայերեն",
"ia": "Interlingua",
"id": "Bahasa Indonesia",
"ig": "Igbo",
"is": "íslenska",
"it": "Italiano",
"ja": "日本語",
"kab": "Taqbaylit",
"ko": "한국어",
"lb": "Lëtzebuergesch",
"lki": "له‌کی",
"lo": "ລາວ",
"lrc": "لۊری شومالی",
"lt": "Lietuvių",
"lv": "Latviešu",
"mk": "македонски",
"mnw": "ဘာသာမန်",
"ms": "Bahasa Malaysia",
"nb": "Norsk bokmål",
"nl": "Nederlands",
"oc": "Occitan",
"pl": "Polski",
"pms": "Piemontèis",
"pt": "Português",
"pt-br": "Português (Brasil)",
"ro": "Română",
"ru": "русский",
"sc": "Sardu",
"sd": "سنڌي",
"shn": "လိၵ်ႈတႆး",
"sk": "Slovenčina",
"skr-arab": "سرائیکی",
"sl": "Slovenščina",
"sq": "Shqip",
"sr": "српски",
"sr-latn": "Srpski",
"sv": "Svenska",
"ta": "தமிழ்",
"tcy": "ತುಳು",
"te": "తెలుగు",
"th": "ไทย",
"tl": "Tagalog",
"tlh": "tlhIngan Hol",
"tr": "Türkçe",
"ug-arab": " ئۇيغۇرچە",
"uk": "українська",
"ur": "اردو",
"vi": "Tiếng Việt",
"xmf": "მარგალური ნინა",
"yo": "Èdè Yorùbá",
"zh-hans": "简体中文",
"zh-hant": "繁體中文"
}
2 changes: 2 additions & 0 deletions game/views/level.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from game.decor import get_decor_element
from game.models import Level, Attempt, Workspace
from game.theme import get_theme
from game.views.language_code_conversions import language_code_dict
from game.views.level_solutions import solutions
from .helper import renderError

Expand Down Expand Up @@ -253,6 +254,7 @@ def play_level(request, level, from_editor=False):
"prev_level_url": _prev_level_url(level, request.user, night_mode),
"next_level_url": _next_level_url(level, request.user, night_mode),
"flip_night_mode_url": _level_url(level, not night_mode),
"available_language_dict": language_code_dict
},
)

Expand Down

0 comments on commit c6026cf

Please sign in to comment.