Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[i18n] Language switcher for anon users #3104

Merged
merged 4 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions mathesar/templates/mathesar/login_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@
font-size: var(--size-xx-large);
text-align: center;
}
.login-card .language-selector {
display: block;
background-color: transparent;
border: 1px solid var(--slate-200);
border-radius: 0.285rem;
cursor: pointer;
}
@media (max-width: 50rem) {
.unsupported-device {
display: block;
Expand Down Expand Up @@ -192,5 +199,18 @@
<div class="login-card align-center">
<h1>{% block h1 %} {% endblock %}</h1>
{% block box_content %} {% endblock %}
<form action="{% url 'set_language' %}" method="post">{% csrf_token %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add comments where the set_language url coming from

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<input name="next" type="hidden" value="{{ redirect_to }}">
<select name="language" onchange="form.submit()" class="language-selector align-center">
seancolsen marked this conversation as resolved.
Show resolved Hide resolved
{% 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{% endif %}>
{{ language.name_local }} ({{ language.code }})
</option>
{% endfor %}
</select>
</form>
</div>
{% endblock %}
1 change: 1 addition & 0 deletions mathesar/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
path('administration/update/', views.admin_home, name='admin_update'),
path('db/', views.home, name='db_home'),
path('db/<db_name>/', views.schemas, name='schemas'),
path('i18n/', include('django.conf.urls.i18n')),
re_path(
r'^db/(?P<db_name>\w+)/(?P<schema_id>\w+)/',
views.schema_home,
Expand Down