Skip to content

Commit 94e1a47

Browse files
author
Dimitrios Bendilas
authored
Merge pull request #33 from transifex/push-command-ui
Improve UI of push command
2 parents d5a4a1a + bb28c08 commit 94e1a47

1 file changed

Lines changed: 29 additions & 20 deletions

File tree

  • transifex/native/django/management/utils

transifex/native/django/management/utils/push.py

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.conf import settings
77
from django.core.management.utils import handle_extensions
88
from django.utils.encoding import force_text
9+
from transifex.common.console import Color
910
from transifex.native import tx
1011
from transifex.native.django.management.common import SourceStringCollection
1112
from transifex.native.django.management.utils.base import CommandMixin
@@ -80,7 +81,12 @@ def collect_strings(self):
8081
8182
Stores found strings in `self.string_collection`.
8283
"""
83-
self.output('Parsing all files to detect translatable content...')
84+
Color.echo(
85+
'[high]\n'
86+
'##############################################################\n'
87+
'Transifex Native: Parsing files to detect translatable content'
88+
'[end]'
89+
)
8490
files = self._find_files('.', 'push')
8591
for f in files:
8692
extracted = self._extract_strings(f)
@@ -94,10 +100,13 @@ def push_strings(self):
94100
"""Push strings to the CDS."""
95101
total = len(self.string_collection.strings)
96102
if total == 0:
97-
self.output('There are no strings to push to Transifex.')
103+
Color.echo('[warn]There are no strings to push to Transifex.[end]')
98104
return
99105

100-
self.output('Pushing {} source strings to Transifex...'.format(total))
106+
Color.echo(
107+
'Pushing [warn]{}[end] unique translatable strings '
108+
'to Transifex...'.format(total)
109+
)
101110
status_code, response_content = tx.push_source_strings(
102111
self.string_collection.strings.values(), self.purge
103112
)
@@ -144,9 +153,9 @@ def _extract_strings(self, translatable_file):
144153
def _show_collect_results(self):
145154
"""Display results of collecting source strings from files."""
146155
total_strings = sum([x[1] for x in self.stats['strings']])
147-
self.output(
148-
'Processed {} file(s) and found {} translatable strings '
149-
'in {} of them'.format(
156+
Color.echo(
157+
'Processed [warn]{}[end] files and found [warn]{}[end] '
158+
'translatable strings in [warn]{}[end] of them.'.format(
150159
self.stats['processed_files'], total_strings, len(self.stats)
151160
)
152161
)
@@ -166,15 +175,15 @@ def _show_push_results(self, status_code, response_content):
166175
deleted = response_content.get('deleted')
167176
failed = response_content.get('failed')
168177
errors = response_content.get('errors', [])
169-
self.output(
170-
'Successfully pushed strings to Transifex.\n'
171-
'Status: {code}\n'
172-
'Created strings: {created}\n'
173-
'Updated strings: {updated}\n'
174-
'Skipped strings: {skipped}\n'
175-
'Deleted strings: {deleted}\n'
176-
'Failed strings: {failed}\n'
177-
'Errors: {errors}\n'.format(
178+
Color.echo(
179+
'[green]\nSuccessfully pushed strings to Transifex.[end]\n'
180+
'[high]Status:[end] [warn]{code}[end]\n'
181+
'[high]Created strings:[end] [warn]{created}[end]\n'
182+
'[high]Updated strings:[end] [warn]{updated}[end]\n'
183+
'[high]Skipped strings:[end] [warn]{skipped}[end]\n'
184+
'[high]Deleted strings:[end] [warn]{deleted}[end]\n'
185+
'[high]Failed strings:[end] [warn]{failed}[end]\n'
186+
'[high]Errors:[end] {errors}[end]\n'.format(
178187
code=status_code,
179188
created=created,
180189
updated=updated,
@@ -188,11 +197,11 @@ def _show_push_results(self, status_code, response_content):
188197
else:
189198
message = response_content.get('message')
190199
details = response_content.get('details')
191-
self.output(
192-
'Could not push strings to Transifex.\n'
193-
'Status: {code}\n'
194-
'Message: {message}\n'
195-
'Details: {details}\n'.format(
200+
Color.echo(
201+
'[error]\nCould not push strings to Transifex.[end]\n'
202+
'[high]Status:[end] [warn]{code}[end]\n'
203+
'[high]Message:[end] [warn]{message}[end]\n'
204+
'[high]Details:[end] [warn]{details}[end]\n'.format(
196205
code=status_code,
197206
message=message,
198207
details=json.dumps(details, indent=4),

0 commit comments

Comments
 (0)