Skip to content

Commit

Permalink
Fix language switching bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Merlin Buczek committed Sep 14, 2019
1 parent 16f1bf7 commit fb4848d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion mpicms/base/templatetags/base_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ def is_subscribed(page, user):

@register.simple_tag
def room_link(room):
return get_room_link(room)
return get_room_link(room)


@register.filter
def remove_i18n(url):
if url.startswith('/en') or url.startswith('/de'):
return url[3:]
return url
3 changes: 2 additions & 1 deletion mpicms/templates/menus/main.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load static i18n wagtailcore_tags %}
{% load static i18n wagtailcore_tags base_tags %}

{% get_current_language as LANGUAGE_CODE %}

Expand Down Expand Up @@ -37,6 +37,7 @@
{% else %}
<form action="{% url 'set_language' %}" method="post" id=language_form>
{% csrf_token %}
<input type="hidden" name="next" value="{{ page.get_url|remove_i18n }}" />
<select name="language" onchange="language_form.submit()">
{% endif %}
{% get_available_languages as LANGUAGES %}
Expand Down

0 comments on commit fb4848d

Please sign in to comment.