Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install gettext
run: sudo apt-get update && sudo apt-get install -y gettext
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ APP_LIST ?= accounts aggregator blog contact dashboard djangoproject docs founda
SCSS = djangoproject/scss
STATIC = djangoproject/static

ci: test
ci: compilemessages test
@python -m coverage report

compilemessages:
python -m manage compilemessages

collectstatics: compile-scss
python -m manage collectstatic --noinput

Expand Down
6 changes: 6 additions & 0 deletions djangoproject/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,14 @@

TIME_ZONE = "America/Chicago"

# Internationalization settings

USE_I18N = True

# Django discovers locale directories in the dashboard and docs apps
# on its own, but the main project locale/ directory needs to be
# explicitly listed here.
LOCALE_PATHS = [str(BASE_DIR.joinpath("locale/"))]

USE_TZ = False

Expand Down
38 changes: 38 additions & 0 deletions djangoproject/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,49 @@
from django.core.management import call_command
from django.test import TestCase
from django.urls import NoReverseMatch, get_resolver
from django.utils.translation import activate, gettext as _
from django_hosts.resolvers import reverse

from docs.models import DocumentRelease, Release


class LocaleSmokeTests(TestCase):
"""
Smoke test a translated string from each of the 3 locale directories
(one defined in settings.LOCALE_PATHS, plus the dashboard and docs apps).
"""

def test_dashboard_locale(self):
"""dashboard/locale/ should contain translations for 'Development dashboard'"""
activate("fr")
translated = _("Development dashboard")
self.assertEqual(
translated,
"Tableau de bord de développement",
msg="dashboard/locale/ translation not loaded or incorrect",
)

def test_docs_locale(self):
"""docs/locale/ should contain translations for 'Using Django'"""
activate("fr")
translated = _("Using Django")
self.assertEqual(
translated,
"Utilisation de Django",
msg="docs/locale/ translation not loaded or incorrect",
)

def test_project_locale(self):
"""locale/ should contain translations for 'Fundraising'"""
activate("fr")
translated = _("Fundraising")
self.assertEqual(
translated,
"Levée de fonds",
msg="project-level locale/ translation not loaded or incorrect",
)


class TemplateViewTests(TestCase):
"""
Tests for views that are instances of TemplateView.
Expand Down
1 change: 1 addition & 0 deletions update-translations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

set -ex

# Any non-app directories added here must also be added to settings.LOCALE_PATHS
LOCALE_DIRS="dashboard/locale/ docs/locale/ locale/"

tx pull -a -f --minimum-perc=70
Expand Down