From 2fce3c503508a932d7e974d41ff15ad4bf86a79b Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 3 Sep 2013 02:34:47 +0200 Subject: First work on i18n form to change language --- example_project/settings.py | 7 +++++++ ishtar_common/static/js/ishtar.js | 4 ++++ ishtar_common/templates/base.html | 9 +++++++++ ishtar_common/urls.py | 2 ++ 4 files changed, 22 insertions(+) diff --git a/example_project/settings.py b/example_project/settings.py index 983339ee5..40aa25066 100644 --- a/example_project/settings.py +++ b/example_project/settings.py @@ -4,6 +4,8 @@ import os +from django.utils.translation import gettext_lazy as _ + DEBUG = False DEBUG_TOOLBAR = False TEMPLATE_DEBUG = DEBUG @@ -52,6 +54,11 @@ USE_I18N = True # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale USE_L10N = True +LANGUAGES = ( + ('fr', _('Français')), + ('en', _('Anglais')), +) +DEFAULT_LANGUAGE = 1 # Absolute path to the directory that holds media. # Example: "/home/media/media.lawrence.com/" diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 08e500425..72da8fdda 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -41,6 +41,9 @@ $(document).ready(function(){ $('#to_bottom_arrow').hide(); $('#to_top_arrow').hide(); } + $('#language_selector').change(function(){ + $('#language_form').submit(); + }); }); $('#to_bottom_arrow').live('click', function(){ @@ -51,6 +54,7 @@ $('#to_top_arrow').live('click', function(){ $("html, body").animate({ scrollTop: 0}, 1000); }); + $("#main_menu ul li").live('click', function(){ var current_id = $(this).attr('id'); console.log(current_id); diff --git a/ishtar_common/templates/base.html b/ishtar_common/templates/base.html index 2f197a841..0d0df59e5 100644 --- a/ishtar_common/templates/base.html +++ b/ishtar_common/templates/base.html @@ -30,6 +30,15 @@ {% trans "Log in" %} {% endif %} {% endblock %} + {% comment %} +
+ {% csrf_token %} + +
{% endcomment %}