Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for internationalisation and localisation and French as a language #27

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
21 changes: 21 additions & 0 deletions core/settings_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,18 @@
import os
from pathlib import Path


def gettext(s):
amakarudze marked this conversation as resolved.
Show resolved Hide resolved
"""
i18n passthrough
"""
return s

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

SITE_ID = 1

# Application definition

INSTALLED_APPS = [
Expand All @@ -41,6 +50,7 @@
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
"django.middleware.locale.LocaleMiddleware",
]

ROOT_URLCONF = "core.urls"
Expand Down Expand Up @@ -101,8 +111,19 @@

USE_I18N = True

USE_L10N = True

USE_TZ = True

LANGUAGE_CODE = "en"

LANGUAGES = [
('en', 'English'),
('fr', 'French'),
]

LOCALE_PATHS = [os.path.join(BASE_DIR, 'locale')]


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
Expand Down
2 changes: 2 additions & 0 deletions core/settings_dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

SECRET_KEY = "not really a secret"
DEBUG = True
BASE_URL = "localhost"
ALLOWED_HOSTS = []

MIDDLEWARE += [ # noqa: F405
"django_browser_reload.middleware.BrowserReloadMiddleware",
Expand Down
4 changes: 2 additions & 2 deletions core/settings_prod.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from .settings_base import * # noqa: F403
import dj_database_url

ALLOWED_HOSTS = ["localhost", "127.0.0.1", "2025.djangocon.africa"]

ALLOWED_HOSTS = ["2025.djangocon.africa"]
BASE_URL = "https://2025.djangocon.africa"

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ["DJANGO_SECRET"] # noqa: F405
Expand Down
11 changes: 8 additions & 3 deletions core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.conf.urls.i18n import i18n_patterns
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
path("", include("website.urls")),
path("accounts/", include("django.contrib.auth.urls")),
path("admin/", admin.site.urls),
path("__reload__/", include("django_browser_reload.urls")),
path('i18n/', include('django.conf.urls.i18n')),
]

urlpatterns += i18n_patterns(
path("accounts/", include("django.contrib.auth.urls")),
path("", include("website.urls")),
path("admin/", admin.site.urls),
)
Loading
Loading