From 8f0c2f3159b10ae2fffc2133ceeec0a53236173e Mon Sep 17 00:00:00 2001
From: "Christopher C. Wells"
Date: Sat, 13 Apr 2019 19:13:14 -0700
Subject: [PATCH 01/27] Add locale middleware.
---
babybuddy/settings/base.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/babybuddy/settings/base.py b/babybuddy/settings/base.py
index c49e19c8..7969f6d4 100644
--- a/babybuddy/settings/base.py
+++ b/babybuddy/settings/base.py
@@ -53,10 +53,9 @@ INSTALLED_APPS = [
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
-
'whitenoise.middleware.WhiteNoiseMiddleware',
-
'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
@@ -120,6 +119,10 @@ USE_L10N = True
USE_TZ = True
+LOCALE_PATHS = [
+ os.path.join(BASE_DIR, "locale"),
+]
+
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
From 0e4d80dab06e64e5f9bbceede1b433a7cfc0358d Mon Sep 17 00:00:00 2001
From: "Christopher C. Wells"
Date: Sat, 13 Apr 2019 20:07:46 -0700
Subject: [PATCH 02/27] Add cookie-based language selection to user settings.
This will likely be refactored to use a database column instead of dropping a cookie.
---
.../babybuddy/user_settings_form.html | 19 ++++++++++++++++++-
babybuddy/urls.py | 1 +
babybuddy/views.py | 2 ++
3 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/babybuddy/templates/babybuddy/user_settings_form.html b/babybuddy/templates/babybuddy/user_settings_form.html
index 26b73c01..c8f188ea 100644
--- a/babybuddy/templates/babybuddy/user_settings_form.html
+++ b/babybuddy/templates/babybuddy/user_settings_form.html
@@ -1,5 +1,5 @@
{% extends 'babybuddy/page.html' %}
-{% load widget_tweaks %}
+{% load i18n widget_tweaks %}
{% block title %}User Settings{% endblock %}
@@ -41,6 +41,23 @@
{% include 'babybuddy/form_field.html' %}
{% endwith %}
+
diff --git a/babybuddy/templates/babybuddy/form.html b/babybuddy/templates/babybuddy/form.html
index 83dc2555..25bf20dc 100644
--- a/babybuddy/templates/babybuddy/form.html
+++ b/babybuddy/templates/babybuddy/form.html
@@ -1,4 +1,4 @@
-{% load widget_tweaks %}
+{% load i18n widget_tweaks %}
{% endfor %}
-
+
diff --git a/babybuddy/templates/babybuddy/messages.html b/babybuddy/templates/babybuddy/messages.html
index 45627ffe..c751a753 100644
--- a/babybuddy/templates/babybuddy/messages.html
+++ b/babybuddy/templates/babybuddy/messages.html
@@ -1,3 +1,5 @@
+{% load i18n %}
+
{% block messages %}
{% if messages %}
{% for message in messages %}
@@ -13,12 +15,12 @@
{% if form.non_field_errors %}
{% for error in form.non_field_errors %}
- Error: {{ error }}
+ {% blocktrans %}Error: {{ error }}{% endblocktrans %}
{% endfor %}
{% elif form.errors %}
- Error: Some fields have errors. See below for details.
+ {% blocktrans %}Error: Some fields have errors. See below for details. {% endblocktrans %}
{% endif %}
{% endif %}
diff --git a/babybuddy/templates/babybuddy/nav-dropdown.html b/babybuddy/templates/babybuddy/nav-dropdown.html
index 43d4013b..1bace63c 100644
--- a/babybuddy/templates/babybuddy/nav-dropdown.html
+++ b/babybuddy/templates/babybuddy/nav-dropdown.html
@@ -1,5 +1,5 @@
{% extends 'babybuddy/base.html' %}
-{% load babybuddy_tags static timers %}
+{% load babybuddy_tags i18n static timers %}
{% block nav %}