Set locale properly if locale is already in query string (#4733)

This commit is contained in:
Raphael Michel
2025-01-14 18:52:02 +01:00
committed by GitHub
parent bc32fe91a6
commit df785f8c6d
2 changed files with 4 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
{% extends "pretixpresale/base.html" %}
{% load urlreplace %}
{% load i18n %}
{% load static %}
{% load thumb %}
@@ -44,7 +45,7 @@
<nav class="locales" aria-label="{% trans "select language" %}">
<ul>
{% for l in languages %}
<li><a href="{% url "presale:locale.set" %}?locale={{ l.code }}&next={{ request.path }}{% if request.META.QUERY_STRING %}%3F{{ request.META.QUERY_STRING|urlencode }}{% endif %}" class="{% if l.code == request.LANGUAGE_CODE %}active{% endif %}" rel="nofollow" lang="{{ l.code }}" hreflang="{{ l.code }}"
<li><a href="{% url "presale:locale.set" %}?locale={{ l.code }}&next={{ request.path }}{% if request.META.QUERY_STRING %}%3F{% url_replace request "locale" "" %}{% endif %}" class="{% if l.code == request.LANGUAGE_CODE %}active{% endif %}" rel="nofollow" lang="{{ l.code }}" hreflang="{{ l.code }}"
aria-label="{% language l.code %}{% blocktrans trimmed with language=l.name_local %}
Website in {{ language }}
{% endblocktrans %}{% endlanguage %}">{{ l.name_local }}</a></li>

View File

@@ -1,4 +1,5 @@
{% extends "pretixpresale/base.html" %}
{% load urlreplace %}
{% load i18n %}
{% load static %}
{% load thumb %}
@@ -26,7 +27,7 @@
{% if organizer.settings.locales|length > 1 %}
<nav class="locales" aria-label="{% trans "select language" %}">
{% for l in languages %}
<a href="{% url "presale:locale.set" %}?locale={{ l.code }}&next={{ request.path }}%3F{{ request.META.QUERY_STRING|urlencode }}" class="{% if l.code == request.LANGUAGE_CODE %}active{% endif %}" rel="nofollow"
<a href="{% url "presale:locale.set" %}?locale={{ l.code }}&next={{ request.path }}{% if request.META.QUERY_STRING %}%3F{% url_replace request "locale" "" %}{% endif %}" class="{% if l.code == request.LANGUAGE_CODE %}active{% endif %}" rel="nofollow"
lang="{{ l.code }}" hreflang="{{ l.code }}"
aria-label="{% language l.code %}{% blocktrans trimmed with language=l.name_local %}
Website in {{ language }}