Skip to content

Commit

Permalink
Merge pull request #4609 from kobotoolbox/3804-language-selector-in-a…
Browse files Browse the repository at this point in the history
…ll-django-templates

Make language selector being available in all templates
  • Loading branch information
JacquelineMorrissette committed Sep 1, 2023
2 parents 5ac0c9c + a93f911 commit 26ae72b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
26 changes: 26 additions & 0 deletions kobo/apps/accounts/templates/account/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,32 @@
{% endif %}
{% endblock %}

{% block language_selector %}
{% load i18n %}
{# This is the language switcher dropdown #}
<form action="{% url 'set_language' %}" method="post" class="language-switcher">
{% csrf_token %}

<input name="next" type="hidden" value="{{ redirect_to }}" />

<select name="language" onchange="this.form.submit()">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option
value="{{ language.code }}"
{% if language.code == LANGUAGE_CODE %}selected="selected"{% endif %}
>
{{ language.name_local }}
</option>
{% endfor %}
</select>

<input type="submit" value="Go" class="hidden" />
</form>
{% endblock %}

{% block content %}
{% endblock %}

Expand Down
19 changes: 2 additions & 17 deletions kobo/apps/accounts/templates/account/signup.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
{% extends "account/base.html" %} {% load static %}
{% extends "account/base.html" %}
{% load static %}
{% load i18n %}
{% load account get_provider_appname socialaccount %}

{% block content %}
<form action="{% url 'set_language' %}" method="post" class="language-switcher">
{% csrf_token %}
<input name="next" type="hidden" value="{{ redirect_to }}" />
<select name="language" onchange="this.form.submit()">
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
{% for language in languages %}
<option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected="selected"{% endif %}>
{{ language.name_local }}
</option>
{% endfor %}
</select>
<input type="submit" value="Go" class="hidden" />
</form>

<form action="." method="post" class="registration registration--register">
<div class="registration--logo">
<a href="/">
Expand Down
1 change: 1 addition & 0 deletions kpi/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
</head>
<body>
<div class="registration__bg">
{% block language_selector %}{% endblock %}
{% block content %}{% endblock %}
{% if livereload_address %}
<script src="{{livereload_address}}"></script>
Expand Down

0 comments on commit 26ae72b

Please sign in to comment.