Skip to content

Commit 2f518da

Browse files
author
jruigrok
committed
Use Django's get_language() method to get the language code for both static
and dynamic translation. See: #201 Submitted by: Florian Sening git-svn-id: http://svn.edgewall.org/repos/babel/contrib/django@492 59ecc08e-a131-0410-9ea7-d4c0f28ac310
1 parent 234d2cf commit 2f518da

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

babeldjango/middleware.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# Copyright (C) 2007 Edgewall Software
3+
# Copyright (C) 2007-2010 Edgewall Software
44
# All rights reserved.
55
#
66
# This software is licensed as described in the file COPYING, which
@@ -12,7 +12,7 @@
1212
# history and logs, available at http://babel.edgewall.org/log/.
1313

1414
from babel import Locale, UnknownLocaleError
15-
from django.conf import settings
15+
from django.utils.translation import get_language
1616
try:
1717
from threading import local
1818
except ImportError:
@@ -38,7 +38,7 @@ class LocaleMiddleware(object):
3838

3939
def process_request(self, request):
4040
try:
41-
code = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE)
41+
code = getattr(request, 'LANGUAGE_CODE', get_language())
4242
locale = Locale.parse(code, sep='-')
4343
except (ValueError, UnknownLocaleError):
4444
pass

babeldjango/templatetags/babel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from django.conf import settings
1515
from django.template import Library
16-
from django.utils.translation import to_locale
16+
from django.utils.translation import to_locale, get_language
1717
try:
1818
from pytz import timezone
1919
except ImportError:
@@ -30,7 +30,7 @@
3030
def _get_format():
3131
locale = get_current_locale()
3232
if not locale:
33-
locale = Locale.parse(to_locale(settings.LANGUAGE_CODE))
33+
locale = Locale.parse(to_locale(get_language()))
3434
if timezone:
3535
tzinfo = timezone(settings.TIME_ZONE)
3636
else:

0 commit comments

Comments
 (0)