--- a/web/tralalere/settings.py Mon Jun 11 15:47:37 2012 +0200
+++ b/web/tralalere/settings.py Mon Jun 11 16:48:14 2012 +0200
@@ -32,7 +32,7 @@
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
-LANGUAGE_CODE = 'fr-fr'
+LANGUAGE_CODE = 'fr-FR'
ugettext = lambda s:s
@@ -49,7 +49,7 @@
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
-USE_L10N = True
+USE_L10N = False
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
@@ -106,7 +106,7 @@
)
MIDDLEWARE_CLASSES = (
- 'django.middleware.gzip.GZipMiddleware',
+ 'tralalere.utils.ForceDefaultLanguageMiddleware',
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
--- a/web/tralalere/templates/home.html Mon Jun 11 15:47:37 2012 +0200
+++ b/web/tralalere/templates/home.html Mon Jun 11 16:48:14 2012 +0200
@@ -2,6 +2,7 @@
{% block main_content %}
{% load thumbnail %}
{% load i18n %}
+{% load l10n %}
<div class="home-header">
<h1>Musitag</h1>
<h2>{% trans "Mets tes couleurs, tes émotions<br />et ta voix sur la musique !" %}</h2>
@@ -10,7 +11,7 @@
{% for content in contents %}
<div class="home-media">
<a href="{% url player content.iri_id %}">
- {% thumbnail content.image "135x120" format="PNG" crop="center" as im %}<img class="home-media-image" src="{{im.url}}" width="{{ im.width }}" height="{{ im.height }}" />{% endthumbnail %}
+ {% thumbnail content.image "135x120" format="PNG" crop="center" as im %}<img class="home-media-image" src="{{im.url}}" width="{{ im.width|unlocalize }}" height="{{ im.height|unlocalize }}" />{% endthumbnail %}
</a>
<h3>
<a href="{% url player content.iri_id %}">{{content.title}}</a>
@@ -26,7 +27,7 @@
{% if tag.scale == 1 %}
<div class="tag-container-50" >
{% else %}
- <div class="tag-container-50" style="-webkit-transform-origin: bottom left; -webkit-transform: scale({{tag.scale}}); -moz-transform-origin: bottom left; -moz-transform: scale({{tag.scale}});">
+ <div class="tag-container-50" style="-webkit-transform-origin: bottom left; -webkit-transform: scale({{tag.scale|unlocalize}}); -moz-transform-origin: bottom left; -moz-transform: scale({{tag.scale|unlocalize}});">
{% endif %}
<div class="tag-shadow"></div>
<div class="tag-color tag-{{tag.tag}}"></div>
@@ -42,7 +43,7 @@
{% if tag.scale == 1 %}
<div class="tag-container-50">
{% else %}
- <div class="tag-container-50" style="-webkit-transform-origin: bottom left; -webkit-transform: scale({{tag.scale}}); -moz-transform-origin: bottom left; -moz-transform: scale({{tag.scale}});">
+ <div class="tag-container-50" style="-webkit-transform-origin: bottom left; -webkit-transform: scale({{tag.scale|unlocalize}}); -moz-transform-origin: bottom left; -moz-transform: scale({{tag.scale|unlocalize}});">
{% endif %}
<div class="tag-shadow"></div>
<div class="tag-color"></div>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/tralalere/utils.py Mon Jun 11 16:48:14 2012 +0200
@@ -0,0 +1,13 @@
+class ForceDefaultLanguageMiddleware(object):
+ """
+ Ignore Accept-Language HTTP headers
+
+ This will force the I18N machinery to always choose settings.LANGUAGE_CODE
+ as the default initial language, unless another one is set via sessions or cookies
+
+ Should be installed *before* any middleware that checks request.META['HTTP_ACCEPT_LANGUAGE'],
+ namely django.middleware.locale.LocaleMiddleware
+ """
+ def process_request(self, request):
+ if request.META.has_key('HTTP_ACCEPT_LANGUAGE'):
+ del request.META['HTTP_ACCEPT_LANGUAGE']