Output current language code in HTML header (#5091)

Fixes #5051
pull/5113/head
Matt Westcott 2019-02-19 12:31:36 +00:00
rodzic 61e1e4c2f9
commit 8b7efc0b16
5 zmienionych plików z 17 dodań i 2 usunięć

Wyświetl plik

@ -22,6 +22,7 @@ Changelog
* Fix: `routablepageurl` tag now correctly omits domain part when multiple sites exist at the same root (Gassan Gousseinov)
* Fix: Added missing collection column specifier on document listing template (Sergey Fedoseev)
* Fix: Page Copy will now also copy ParentalManyToMany field relations (LB (Ben Johnston))
* Fix: Admin HTML header now includes correct language code (Matt Westcott)
2.4 (19.12.2018)

Wyświetl plik

@ -37,6 +37,7 @@ Bug fixes
* ``routablepageurl`` tag now correctly omits domain part when multiple sites exist at the same root (Gassan Gousseinov)
* Added missing collection column specifier on document listing template (Sergey Fedoseev)
* Page Copy will now also copy ParentalManyToMany field relations (LB (Ben Johnston))
* Admin HTML header now includes correct language code (Matt Westcott)
Upgrade considerations

Wyświetl plik

@ -1,6 +1,7 @@
<!doctype html>
{% load static i18n %}
<html class="no-js" lang="{{ LANGUAGE_CODE|default:"en-gb" }}">
{% get_current_language as LANGUAGE_CODE %}
<html class="no-js" lang="{{ LANGUAGE_CODE }}">
<head>
<meta charset="utf-8" />
<title>Wagtail - {% block titletag %}{% endblock %}</title>

Wyświetl plik

@ -363,6 +363,9 @@ class TestAccountSection(TestCase, WagtailTestUtils):
# Page should contain a 'Language Preferences' title
self.assertContains(response, "Language Preferences")
# check that current language preference is indicated in HTML header
self.assertContains(response, '<html class="no-js" lang="en">')
def test_language_preferences_view_post(self):
"""
This posts to the language preferences view and checks that the
@ -382,6 +385,10 @@ class TestAccountSection(TestCase, WagtailTestUtils):
# Check that the language preferences are stored
self.assertEqual(profile.preferred_language, 'es')
# check that the updated language preference is now indicated in HTML header
response = self.client.get(reverse('wagtailadmin_home'))
self.assertContains(response, '<html class="no-js" lang="es">')
def test_unset_language_preferences(self):
# Post new values to the language preferences page
post_data = {

Wyświetl plik

@ -1,4 +1,4 @@
from django.test import TestCase
from django.test import TestCase, override_settings
from django.urls import reverse
from wagtail.core.models import Page
@ -50,3 +50,8 @@ class TestLoginView(TestCase, WagtailTestUtils):
login_url = reverse('wagtailadmin_login') + '?next={}'.format(homepage_admin_url)
response = self.client.get(login_url)
self.assertRedirects(response, homepage_admin_url)
@override_settings(LANGUAGE_CODE='de')
def test_language_code(self):
response = self.client.get(reverse('wagtailadmin_login'))
self.assertContains(response, '<html class="no-js" lang="de">')