Skip to content

Commit cbfe4d1

Browse files
author
cmlenz
committed
BabelDjango: the middleware now falls back to settings.LANGUAGE_CODE when the Django LocaleMiddleware hasn't done its thing.
git-svn-id: http://svn.edgewall.org/repos/babel/contrib/django@294 59ecc08e-a131-0410-9ea7-d4c0f28ac310
1 parent cc380b9 commit cbfe4d1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

babeldjango/middleware.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +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
1516
try:
1617
from threading import local
1718
except ImportError:
@@ -37,7 +38,8 @@ class LocaleMiddleware(object):
3738

3839
def process_request(self, request):
3940
try:
40-
locale = Locale.parse(request.LANGUAGE_CODE, sep='-')
41+
code = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE)
42+
locale = Locale.parse(code, sep='-')
4143
except (ValueError, UnknownLocaleError):
4244
pass
4345
else:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
setup(
2121
name = 'BabelDjango',
2222
description = 'Utilities for using Babel in Django',
23-
version = '0.1',
23+
version = '0.2',
2424
license = 'BSD',
2525
author = 'Edgewall Software',
2626
author_email = '[email protected]',

0 commit comments

Comments
 (0)