Commits

David Paccoud  committed a7f2f19 Merge

Merged localeurl from default

  • Participants
  • Parent commits 272fb8e, c775332
  • Branches modeltranslation

Comments (0)

Files changed (4)

File requirements.txt

 South==0.7.3
 distribute==0.6.15
 -e git+https://github.com/nathanborror/django-basic-apps.git@84f5ebdcc0d4c54b973d89634ae2135822c4d26f#egg=django_basic_apps-dev
+django-localeurl==1.4
 -e svn+http://django-modeltranslation.googlecode.com/svn/trunk@106#egg=django_modeltranslation-0.2-py2.6-dev_r106
 django-tagging==0.3.1
 psycopg2==2.4
     'django.template.loaders.app_directories.Loader',
 )
 
+TEMPLATE_CONTEXT_PROCESSORS = (
+    'django.contrib.auth.context_processors.auth',
+    'django.core.context_processors.debug',
+    'django.core.context_processors.i18n',
+    'django.core.context_processors.media',
+    'django.core.context_processors.request',
+    'django.contrib.messages.context_processors.messages',
+)
+
 MIDDLEWARE_CLASSES = (
+    'localeurl.middleware.LocaleURLMiddleware',
     'django.middleware.common.CommonMiddleware',
     'django.contrib.sessions.middleware.SessionMiddleware',
     'django.middleware.csrf.CsrfViewMiddleware',
 )
 
 INSTALLED_APPS = (
+    'localeurl',
     'django.contrib.auth',
     'django.contrib.contenttypes',
     'django.contrib.sessions',

File templates/base.html

 <!DOCTYPE html>
-<html lang="fr">
+<html lang="{{ LANGUAGE_CODE }}">
   <head>
     <meta charset="utf-8" />
     <title>{% block title %}{% endblock %}</title>
   <body id="{% block body_id %}{% endblock %}" class="{% block body_class %}{% endblock %}">
     <div id="body">
       {% block body %}
+        {% block lang %}{% endblock %}
         <div class="content_title">
           {% block content_title %}{% endblock %}
         </div>

File templates/blog/base_blog.html

 {% extends "base.html" %}
+{% load localeurl_tags %}
 
+{% block body_class %}blog{% endblock %}
 
-{% block body_class %}blog{% endblock %}
+{% block lang %}
+  <div id="lang">
+    {% for lang in LANGUAGES %}
+      {% ifequal lang.0 LANGUAGE_CODE %}
+        <span class="selected">{{ lang.1 }}</span>
+      {% else %}
+        <span><a href="{{ request.path|chlocale:lang.0 }}">{{ lang.1 }}</a></span>
+      {% endifequal %}
+    {% endfor %}
+  </div>
+{% endblock %}