66from django .conf import settings
77from django .core .management .utils import handle_extensions
88from django .utils .encoding import force_text
9+ from transifex .common .console import Color
910from transifex .native import tx
1011from transifex .native .django .management .common import SourceStringCollection
1112from 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] \n Successfully 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] \n Could 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