Skip to content

Commit

Permalink
Display currently selected course language
Browse files Browse the repository at this point in the history
Fixes #849
  • Loading branch information
ihalaij1 authored and murhum1 committed Jan 13, 2025
1 parent 35fef98 commit b6afbe6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
14 changes: 10 additions & 4 deletions course/templates/course/_course_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

{% prepare_course_menu %}

{% get_current_language as LANGUAGE_CODE %}

<li>
<a href="#course-content" class="skip-link page-skip-link hidden-xs">
{% translate "SKIP_COURSE_NAVIGATION" %}
Expand All @@ -23,13 +25,15 @@ <h4 id="course-menu-heading">{% translate "LANGUAGE" %}</h4>
{% translate "CHANGE_LANGUAGE" %} <span class="caret"></span>
</a>
<ul class="dropdown-menu" aria-labelledby="lang-dropdown-mobile">
{% for language in instance.language|list_unselected %}
{% for language in instance.language|list_languages %}
<li role="none">
<form action="{{ instance|url:'set-enrollment-language' }}" method="post">
{% csrf_token %}
<input name="next" type="hidden" value="{{ request.get_full_path }}" />
<input name="language" type="hidden" value="{{ language }}" />
<button type="submit" class="btn">{{ language|language_name_local }}</button>
<button type="submit" class="btn" {% if LANGUAGE_CODE == language %}aria-current="true"{% endif %}>
{{ language|language_name_local }} {% if LANGUAGE_CODE == language %}<span class="glyphicon glyphicon-ok"></span>{% endif %}
</button>
</form>
</li>
{% endfor %}
Expand All @@ -47,13 +51,15 @@ <h4 id="course-menu-heading">{% translate "LANGUAGE" %}</h4>
<span>Language</span>
</button>
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="lang-dropdown-desktop">
{% for language in instance.language|list_unselected %}
{% for language in instance.language|list_languages %}
<li>
<form action="{{ instance|url:'set-enrollment-language' }}" method="post">
{% csrf_token %}
<input name="next" type="hidden" value="{{ request.get_full_path }}" />
<input name="language" type="hidden" value="{{ language }}" />
<button type="submit" class="btn">{{ language|language_name_local }}</button>
<button type="submit" class="btn" {% if LANGUAGE_CODE == language %}aria-current="true"{% endif %}>
{{ language|language_name_local }} {% if LANGUAGE_CODE == language %}<span class="glyphicon glyphicon-ok"></span>{% endif %}
</button>
</form>
</li>
{% endfor %}
Expand Down
4 changes: 2 additions & 2 deletions course/templatetags/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ def parse_localization(entry):


@register.filter
def list_unselected(langs):
listed = list(filter(lambda x: x and x != get_language(), langs.split("|")))
def list_languages(langs):
listed = list(filter(lambda x: x, langs.split("|")))
return listed


Expand Down

0 comments on commit b6afbe6

Please sign in to comment.