Skip to content

Commit

Permalink
🌐(search) replace gettext by ugettext_lazy in the defaults file
Browse files Browse the repository at this point in the history
Some section titles on the search page are not translating properly
with gettext. Using ugettext_lazy instead fixes the problem.
  • Loading branch information
2018D committed Apr 5, 2019
1 parent 0b17e32 commit a55cb36
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/richie/apps/search/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
from django.conf import settings
from django.utils.functional import lazy
from django.utils.translation import gettext as _
from django.utils.translation import ugettext_lazy as _

# The React i18n library only works with ISO15897 locales (e.g. fr_FR)
# Django also supports ISO639-1 language codes without a region (e.g. fr) which is sufficient
Expand Down
24 changes: 23 additions & 1 deletion tests/apps/search/test_query_courses_edge_cases.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Tests for environment ElasticSearch support."""
# pylint: disable=too-many-lines
import json
import random
from http.cookies import SimpleCookie
from unittest import mock

from django.conf import settings
Expand Down Expand Up @@ -104,6 +104,28 @@ def prepare_index(self, courses):
)
indices_client.refresh()

def test_query_courses_filter_box_titles_french(self, *_):
"""
Filter box titles should be in french when the language cookie is set.
"""

self.prepare_index([])
self.client.cookies = SimpleCookie({"django_language": "fr"})
response = self.client.get(f"/api/v1.0/courses/")
self.assertEqual(response.status_code, 200)
content = json.loads(response.content)
self.assertEqual(
[v["human_name"] for v in content["filters"].values()],
[
"Nouveaux cours",
"Disponibilité",
"Sujets",
"Niveaux",
"Établissements",
"Langues",
],
)

def test_query_courses_rare_facet_force(self, *_):
"""
A facet that is selected in the querystring should always be included in the result's
Expand Down

0 comments on commit a55cb36

Please sign in to comment.