From a7ec9b173d4c958109a482f89b27dfb6d8d955e9 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Sat, 2 Jun 2018 19:04:32 +0200 Subject: [PATCH] Add a basic language switcher in the home footer fix #74 --- umap/settings/base.py | 16 ++++++++++++++++ umap/static/umap/nav.css | 6 ++++++ umap/templates/umap/content_footer.html | 14 ++++++++++++++ umap/urls.py | 1 + 4 files changed, 37 insertions(+) diff --git a/umap/settings/base.py b/umap/settings/base.py index a1eddb9c..619d616d 100644 --- a/umap/settings/base.py +++ b/umap/settings/base.py @@ -2,6 +2,7 @@ # Import global settings to make it easier to extend settings. from django.conf.global_settings import * # pylint: disable=W0614,W0401 from django.template.defaultfilters import slugify +from django.conf.locale import LANG_INFO # ============================================================================= # Generic Django project settings @@ -10,6 +11,21 @@ from django.template.defaultfilters import slugify DEBUG = True SITE_ID = 1 +# Add languages we're missing from Django +LANG_INFO.update({ + 'am-et': { + 'bidi': False, + 'name': 'Amharic', + 'code': 'am-et', + 'name_local': 'አማርኛ' + }, + 'zh': { + 'bidi': False, + 'code': 'zh', + 'name': 'Chinese', + 'name_local': '简体中文', + }, +}) # Local time zone for this installation. Choices can be found here: # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name TIME_ZONE = 'UTC' diff --git a/umap/static/umap/nav.css b/umap/static/umap/nav.css index d98985ad..48efa3c8 100644 --- a/umap/static/umap/nav.css +++ b/umap/static/umap/nav.css @@ -22,6 +22,12 @@ footer a.branding { color: #8F96A3; display: inline-block; } + +footer .i18n_switch { + display: inline-block; +} + + .umap-nav { display: flex; flex-direction: column; diff --git a/umap/templates/umap/content_footer.html b/umap/templates/umap/content_footer.html index f87db163..43239bc6 100644 --- a/umap/templates/umap/content_footer.html +++ b/umap/templates/umap/content_footer.html @@ -1,3 +1,17 @@ +{% load i18n %} + diff --git a/umap/urls.py b/umap/urls.py index 03526259..b4ec5d5d 100644 --- a/umap/urls.py +++ b/umap/urls.py @@ -31,6 +31,7 @@ urlpatterns = [ url(r'^change-password-done/', auth_views.password_change_done, {'template_name': 'umap/password_change_done.html'}, name='password_change_done'), + url(r'^i18n/', include('django.conf.urls.i18n')), ] i18n_urls = [