Skip to content

Commit

Permalink
support django 1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
orf authored and Thomas Grainger committed Jun 7, 2017
1 parent ec0ebfa commit 62f203f
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 23 deletions.
32 changes: 23 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
language: python
python: 3.4
python: 3.5
sudo: false
env:
- TOX_ENV=docs
- TOX_ENV=lint
- TOX_ENV=py27-django18
- TOX_ENV=py27-django19
- TOX_ENV=py27-django110
- TOX_ENV=py27-djangomaster
- TOX_ENV=py27-django111
- TOX_ENV=py33-django18
- TOX_ENV=py34-django18
- TOX_ENV=py34-django19
- TOX_ENV=py34-django110
- TOX_ENV=py34-django111
- TOX_ENV=py34-djangomaster
install:
- pip install tox
script:
- tox -e $TOX_ENV
cache:
directories:
- $HOME/.cache/pip
- TOX_ENV=py35-django18
- TOX_ENV=py35-django19
- TOX_ENV=py35-django110
- TOX_ENV=py35-django111
- TOX_ENV=py35-djangomaster
matrix:
include:
- env: TOX_ENV=py36-django18
python: "3.6"
- env: TOX_ENV=py36-django19
python: "3.6"
- env: TOX_ENV=py36-django110
python: "3.6"
- env: TOX_ENV=py36-django111
python: "3.6"
- env: TOX_ENV=py36-djangomaster
python: "3.6"
install: pip install tox
script: tox -e $TOX_ENV
cache: pip
10 changes: 8 additions & 2 deletions django_babel/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
from django.template.base import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
from django.utils.translation import trim_whitespace
from django.utils.encoding import smart_text
from django.utils.translation.trans_real import (
inline_re, block_re, endblock_re, plural_re, constant_re)

try:
from django.utils.translation.trans_real import (
inline_re, block_re, endblock_re, plural_re, constant_re)
except ImportError:
# Django 1.11+
from django.utils.translation.template import (
inline_re, block_re, endblock_re, plural_re, constant_re)


def join_tokens(tokens, trim=False):
Expand Down
16 changes: 8 additions & 8 deletions django_babel/templatetags/babel.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,41 +32,41 @@ def _get_format():
return babel_support.Format(locale, tzinfo)


@register.filter
def datefmt(date=None, format='medium'):
return _get_format().date(date, format=format)
datefmt = register.filter(datefmt)


@register.filter
def datetimefmt(datetime=None, format='medium'):
return _get_format().datetime(datetime, format=format)
datetimefmt = register.filter(datetimefmt)


@register.filter
def timefmt(time=None, format='medium'):
return _get_format().time(time, format=format)
timefmt = register.filter(timefmt)


@register.filter
def numberfmt(number):
return _get_format().number(number)
numberfmt = register.filter(numberfmt)


@register.filter
def decimalfmt(number, format=None):
return _get_format().decimal(number, format=format)
decimalfmt = register.filter(decimalfmt)


@register.filter
def currencyfmt(number, currency):
return _get_format().currency(number, currency)
currencyfmt = register.filter(currencyfmt)


@register.filter
def percentfmt(number, format=None):
return _get_format().percent(number, format=format)
percentfmt = register.filter(percentfmt)


@register.filter
def scientificfmt(number):
return _get_format().scientific(number)
scientificfmt = register.filter(scientificfmt)
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def read(*parts):
url='https://github.com/python-babel/django-babel/',
packages=find_packages(exclude=('tests',)),
install_requires=[
'django>=1.4,<1.11',
'django>=1.4,<1.12',
'babel>=1.3',
],
classifiers=[
Expand All @@ -37,10 +37,12 @@ def read(*parts):
'Topic :: Software Development :: Libraries :: Python Modules',
'Framework :: Django',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: Implementation :: PyPy',
'Programming Language :: Python :: Implementation :: CPython',
],
Expand Down
5 changes: 3 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = {py27,py34,py35}-django{18,19,110,master}, py33-django18, lint, docs
envlist = py{34,35,36}-djangomaster, py{27,34,35,36}-django{18,19,110,111}, py33-django18, lint, docs

[testenv]
deps =
Expand All @@ -11,6 +11,7 @@ deps =
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
django111: Django>=1.11,<1.12
djangomaster: https://github.com/django/django/archive/master.tar.gz#egg=Django
commands = py.test {posargs}

Expand All @@ -22,5 +23,5 @@ commands =

[testenv:lint]
deps =
flake8==2.4.1
flake8==3.3.0
commands=flake8 django_babel tests

0 comments on commit 62f203f

Please sign in to comment.