Merge pull request #17 from python-babel/regular-python-imports
regular python imports
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
from babel import support as babel_support
|
||||||
|
from babel import core as babel_core
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.template import Library
|
from django.template import Library
|
||||||
from django.utils.translation import to_locale, get_language
|
from django.utils.translation import to_locale, get_language
|
||||||
@@ -10,22 +12,18 @@ except ImportError:
|
|||||||
|
|
||||||
from django_babel.middleware import get_current_locale
|
from django_babel.middleware import get_current_locale
|
||||||
|
|
||||||
babel = __import__('babel', {}, {}, ['core', 'support'])
|
|
||||||
Format = babel.support.Format
|
|
||||||
Locale = babel.core.Locale
|
|
||||||
|
|
||||||
register = Library()
|
register = Library()
|
||||||
|
|
||||||
|
|
||||||
def _get_format():
|
def _get_format():
|
||||||
locale = get_current_locale()
|
locale = get_current_locale()
|
||||||
if not locale:
|
if not locale:
|
||||||
locale = Locale.parse(to_locale(get_language()))
|
locale = babel_core.Locale.parse(to_locale(get_language()))
|
||||||
if timezone:
|
if timezone:
|
||||||
tzinfo = timezone(settings.TIME_ZONE)
|
tzinfo = timezone(settings.TIME_ZONE)
|
||||||
else:
|
else:
|
||||||
tzinfo = None
|
tzinfo = None
|
||||||
return Format(locale, tzinfo)
|
return babel_support.Format(locale, tzinfo)
|
||||||
|
|
||||||
|
|
||||||
def datefmt(date=None, format='medium'):
|
def datefmt(date=None, format='medium'):
|
||||||
|
|||||||
Reference in New Issue
Block a user