Merge pull request #17 from python-babel/regular-python-imports

regular python imports
This commit is contained in:
Thomas Grainger 2015-09-21 23:59:35 +01:00
commit 913e73e02e
1 changed files with 4 additions and 6 deletions

View File

@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
from babel import support as babel_support
from babel import core as babel_core
from django.conf import settings
from django.template import Library
from django.utils.translation import to_locale, get_language
@ -10,22 +12,18 @@ except ImportError:
from django_babel.middleware import get_current_locale
babel = __import__('babel', {}, {}, ['core', 'support'])
Format = babel.support.Format
Locale = babel.core.Locale
register = Library()
def _get_format():
locale = get_current_locale()
if not locale:
locale = Locale.parse(to_locale(get_language()))
locale = babel_core.Locale.parse(to_locale(get_language()))
if timezone:
tzinfo = timezone(settings.TIME_ZONE)
else:
tzinfo = None
return Format(locale, tzinfo)
return babel_support.Format(locale, tzinfo)
def datefmt(date=None, format='medium'):