Skip to content

Commit a7e21a0

Browse files
committed
Save translations in separate directories
Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
1 parent e7dbf39 commit a7e21a0

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

mmdzanata/cli.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import koji
1818
import mmdzanata
1919
import mmdzanata.fedora
20+
import os
2021
import subprocess
2122
import sys
2223

@@ -101,7 +102,15 @@ def extract(ctx, upload):
101102
ctx.parent.obj['branch']),
102103
debug=ctx.parent.obj['debug'])
103104

104-
potfile = "%s.pot" % ctx.parent.obj['zanata_translation_document']
105+
try:
106+
os.mkdir(ctx.parent.obj['branch'], mode=0o0770)
107+
except OSError:
108+
# Directory already exists
109+
pass
110+
111+
potfile = "%s/%s.pot" % (
112+
ctx.parent.obj['branch'],
113+
ctx.parent.obj['zanata_translation_document'])
105114

106115
with open(potfile, mode="wb") as f:
107116
pofile.write_po(f, catalog, sort_by_file=True)
@@ -132,15 +141,15 @@ def extract(ctx, upload):
132141
'--project', ctx.parent.obj['zanata_project'],
133142
'--project-type', 'gettext',
134143
'--project-version', ctx.parent.obj['branch'],
135-
'--src-dir', '.']
144+
'--src-dir', ctx.parent.obj['branch']]
136145
result = subprocess.run(zanata_args, capture_output=True)
137146
if result.returncode:
138147
print(result.stderr.decode('utf-8'))
139148
print(result.stdout.decode('utf-8'))
140149
sys.exit(2)
141150

142151
print("Uploaded translatable strings for %s to Zanata" % (
143-
ctx.obj['branch']))
152+
ctx.parent.obj['branch']))
144153

145154

146155
##############################################################################

0 commit comments

Comments
 (0)