Skip to content

Commit 8a90144

Browse files
committed
Create po and pot files if not existing, plus the basedirs.
1 parent cd82eb0 commit 8a90144

File tree

1 file changed

+19
-1
lines changed
  • django_babel/management/commands

1 file changed

+19
-1
lines changed

django_babel/management/commands/babel.py

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

5959
for path in locale_paths:
6060
potfile = os.path.join(path, '%s.pot' % domain)
61+
62+
if not os.path.exists(path):
63+
os.makedirs(path)
64+
6165
if not os.path.exists(potfile):
62-
continue
66+
with open(potfile, 'wb') as fobj:
67+
fobj.write('')
6368

6469
cmd = ['pybabel', 'extract', '-o', potfile]
6570

@@ -71,6 +76,19 @@ def handle_makemessages(self, **options):
7176
call(cmd)
7277

7378
for locale in locales:
79+
pofile = os.path.join(
80+
os.path.dirname(potfile),
81+
locale,
82+
'LC_MESSAGES',
83+
'%s.po' % domain)
84+
85+
if not os.path.isdir(os.path.dirname(pofile)):
86+
os.makedirs(basedir)
87+
88+
if not os.path.exists(pofile):
89+
with open(pofile, 'wb') as fobj:
90+
fobj.write('')
91+
7492
cmd = ['pybabel', 'update', '-D', domain,
7593
'-i', potfile,
7694
'-d', os.path.relpath(path),

0 commit comments

Comments
 (0)