Browse Source

Fix language switch for missing routes

pull/16/head
Matīss Treinis 4 years ago
parent
commit
3ac9b3c9e6
No known key found for this signature in database GPG Key ID: 3781D64D73F1907F
  1. 7
      commons/templatetags/i18n_utils.py
  2. 2
      www/templates/404.html

7
commons/templatetags/i18n_utils.py

@ -2,6 +2,7 @@ from typing import Dict
from django import template
from django.urls import resolve, reverse
from django.urls.exceptions import Resolver404
from django.utils import translation
register = template.Library()
@ -9,7 +10,11 @@ register = template.Library()
@register.simple_tag(takes_context=True)
def current_path_for_language_code(context: Dict, code: str) -> str:
view = resolve(context['request'].path)
try:
view = resolve(context['request'].path)
except Resolver404:
view = resolve('/')
request_language = translation.get_language()
try:

2
www/templates/404.html

@ -1,7 +1,5 @@
{% extends 'layouts/base.html' %}
{% load i18n %}
{% load static %}
{% load encore %}
{% block title %}{% translate '404 Not Found - AlmaLinux OS' %}{% endblock %}
{% block description %}

Loading…
Cancel
Save