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

Set language cookie when selecting language #577

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions myhpi/static/scss/footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
text-decoration: underline;
}
}

.btn-link {
color: var(--bs-text-light);
text-decoration: none;
padding: 0;
}
}

@media screen and (min-width: 576px) {
Expand Down
11 changes: 8 additions & 3 deletions myhpi/templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
{% endfor %}
<div class="footer-category">
<h2>{% translate "Language" %}</h2>
{% for translation in page.get_translations %}
<a href="{{ translation.url }}">{{ translation.locale }}</a>
{% endfor %}
{% for translation in page.get_translations %}
<form id="language-form-{{ translation.locale }}" action="{% url 'set_language' %}" method="post">
{% csrf_token %}
<input name="next" type="hidden" value="{{ translation.url }}">
<input type="hidden" name="language" value="{{ translation.locale.language_code }}">
<button class="btn btn-link" type="submit">{{ translation.locale }}</button>
</form>
{% endfor %}
</div>
</div>
</footer>
1 change: 1 addition & 0 deletions myhpi/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
".well-known/security.txt",
RedirectView.as_view(url=os.path.join(settings.STATIC_URL, "security.txt")),
),
path("i18n/", include("django.conf.urls.i18n")),
path("", include("myhpi.core.urls")),
]

Expand Down
Loading