Skip to content

Commit 70afcc3

Browse files
author
Thomas Grainger
committed
Merge branch 'master' of git://github.com/EnTeQuAk/django-babel into sync-EnTeQuAk
2 parents 787d102 + 37f2919 commit 70afcc3

File tree

6 files changed

+79
-28
lines changed

6 files changed

+79
-28
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
build
2+
.cache
3+
.coverage
24
dist
35
*.pyc
46
django_babel.egg-info

CHANGELOG.rst

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,45 @@
11
Changelog
22
=========
33

4-
0.4 - `master`_
5-
---------------
4+
0.4.0 - 2015-04-22
5+
------------------
6+
7+
* Add compatibility for Django 1.8
8+
* Add compatibility for latest django master
9+
* Various python 3 fixes
10+
11+
12+
0.3.9 - 2014-12-24
13+
------------------
14+
15+
* Fix dependencies on Django/Babel to use lower-case egg names.
16+
17+
0.3.8 - 2014-10-14
18+
------------------
19+
20+
* Fix old reference to `babeldjango` module in entry points.
21+
22+
0.3.7 - 2014-10-14
23+
------------------
624

7-
.. note:: This version is not yet released and is under active development.
25+
* Fix Python 3.x compatibility in `babel makemessages` command.
26+
27+
0.3.6 - 2014-10-05
28+
------------------
29+
30+
* Django 1.7 compatibility
31+
32+
33+
0.3.5 - 2014-09-10
34+
------------------
35+
36+
* Create .po and .pot files if not existing, plus it's specific base directories.
37+
38+
39+
0.3.4 - 2014-05-25
40+
------------------
841

42+
* Fixed django compatibility
943

1044
0.3.3 - 2014-04-22
1145
------------------

django_babel/extract.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# -*- coding: utf-8 -*-
2-
from django.template import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
2+
try:
3+
from django.template import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
4+
except ImportError:
5+
# Django 1.8 moved most stuff to .base
6+
from django.template.base import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK
7+
38
from django.utils.translation.trans_real import (
49
inline_re, block_re, endblock_re, plural_re, constant_re)
5-
from django.utils.encoding import smart_text as smart_unicode
10+
from django.utils.encoding import smart_text
611

712

813
def extract_django(fileobj, keywords, comment_tags, options):
@@ -38,14 +43,14 @@ def extract_django(fileobj, keywords, comment_tags, options):
3843
yield (
3944
lineno,
4045
'ngettext',
41-
(smart_unicode(u''.join(singular)),
42-
smart_unicode(u''.join(plural))),
46+
(smart_text(u''.join(singular)),
47+
smart_text(u''.join(plural))),
4348
[])
4449
else:
4550
yield (
4651
lineno,
4752
None,
48-
smart_unicode(u''.join(singular)),
53+
smart_text(u''.join(singular)),
4954
[])
5055

5156
intrans = False
@@ -78,22 +83,22 @@ def extract_django(fileobj, keywords, comment_tags, options):
7883
g = g.strip('"')
7984
elif g[0] == "'":
8085
g = g.strip("'")
81-
yield lineno, None, smart_unicode(g), []
86+
yield lineno, None, smart_text(g), []
8287
elif bmatch:
8388
for fmatch in constant_re.findall(t.contents):
84-
yield lineno, None, smart_unicode(fmatch), []
89+
yield lineno, None, smart_text(fmatch), []
8590
intrans = True
8691
inplural = False
8792
singular = []
8893
plural = []
8994
elif cmatches:
9095
for cmatch in cmatches:
91-
yield lineno, None, smart_unicode(cmatch), []
96+
yield lineno, None, smart_text(cmatch), []
9297
elif t.token_type == TOKEN_VAR:
9398
parts = t.contents.split('|')
9499
cmatch = constant_re.match(parts[0])
95100
if cmatch:
96-
yield lineno, None, smart_unicode(cmatch.group(1)), []
101+
yield lineno, None, smart_text(cmatch.group(1)), []
97102
for p in parts[1:]:
98103
if p.find(':_(') >= 0:
99104
p1 = p.split(':', 1)[1]
@@ -105,4 +110,4 @@ def extract_django(fileobj, keywords, comment_tags, options):
105110
p1 = p1.strip("'")
106111
elif p1[0] == '"':
107112
p1 = p1.strip('"')
108-
yield lineno, None, smart_unicode(p1), []
113+
yield lineno, None, smart_text(p1), []

django_babel/management/commands/babel.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,13 @@ def handle_makemessages(self, **options):
6262

6363
for path in locale_paths:
6464
potfile = os.path.join(path, '%s.pot' % domain)
65+
66+
if not os.path.exists(path):
67+
os.makedirs(path)
68+
6569
if not os.path.exists(potfile):
66-
continue
70+
with open(potfile, 'wb') as fobj:
71+
fobj.write(b'')
6772

6873
cmd = ['pybabel', 'extract', '-o', potfile]
6974

@@ -75,6 +80,19 @@ def handle_makemessages(self, **options):
7580
call(cmd)
7681

7782
for locale in locales:
83+
pofile = os.path.join(
84+
os.path.dirname(potfile),
85+
locale,
86+
'LC_MESSAGES',
87+
'%s.po' % domain)
88+
89+
if not os.path.isdir(os.path.dirname(pofile)):
90+
os.makedirs(os.path.dirname(pofile))
91+
92+
if not os.path.exists(pofile):
93+
with open(pofile, 'wb') as fobj:
94+
fobj.write(b'')
95+
7896
cmd = ['pybabel', 'update', '-D', domain,
7997
'-i', potfile,
8098
'-d', os.path.relpath(path),

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@
5454
# built documents.
5555
#
5656
# The short X.Y version.
57-
version = '0.4'
57+
version = '0.3.4'
5858
# The full version, including alpha/beta/rc tags.
59-
release = '0.4-dev'
59+
release = '0.3.4'
6060

6161
# The language for content autogenerated by Sphinx. Refer to documentation
6262
# for a list of supported languages.

setup.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
import os
4-
import sys
54
import codecs
65
from setuptools import setup, find_packages
76

@@ -12,17 +11,11 @@ def read(*parts):
1211
return fp.read()
1312

1413

15-
install_requires = [
16-
'Django>=1.4,<1.9',
17-
'Babel>=1.3',
18-
]
19-
20-
2114
setup(
2215
name='django-babel',
2316
description='Utilities for using Babel in Django',
2417
long_description=read('README.rst') + u'\n\n' + read('CHANGELOG.rst'),
25-
version='0.4-dev',
18+
version='0.4.0',
2619
license='BSD',
2720
author='Christopher Grebs',
2821
author_email='[email protected]',
@@ -31,8 +24,8 @@ def read(*parts):
3124
url='https://github.com/python-babel/django-babel/',
3225
packages=find_packages(exclude=('tests',)),
3326
install_requires=[
34-
'Django>=1.4,<1.8',
35-
'Babel>=1.3',
27+
'django>=1.4,<1.9',
28+
'babel>=1.3',
3629
],
3730
classifiers=[
3831
'Development Status :: 4 - Beta',
@@ -47,14 +40,13 @@ def read(*parts):
4740
'Programming Language :: Python :: 2.6',
4841
'Programming Language :: Python :: 2.7',
4942
'Programming Language :: Python :: 3',
50-
'Programming Language :: Python :: 3.3',
5143
'Programming Language :: Python :: 3.4',
5244
'Programming Language :: Python :: Implementation :: PyPy',
5345
'Programming Language :: Python :: Implementation :: CPython',
5446
],
5547
entry_points={
5648
'babel.extractors': [
57-
'django = babeldjango.extract:extract_django',
49+
'django = django_babel.extract:extract_django',
5850
]
5951
}
6052
)

0 commit comments

Comments
 (0)