@@ -73,8 +73,10 @@ def patched(*args, **kwargs):
73
73
@click .option ('--max-words' ,
74
74
default = None , type = click .INT ,
75
75
help = "Maximum number of words in sentence" )
76
+ @click .option ('--accept-all/--no-accept-all' ,
77
+ default = False , help = "Automatically accept all translations" )
76
78
def cli (pofile , source , target , tier , public_key , private_key , sandbox , debug ,
77
- limit , comment , tone , min_words , max_words ):
79
+ limit , comment , tone , min_words , max_words , accept_all ):
78
80
""" Takes the given pofile and submits its entries to the gengo API for
79
81
translation. Translated strings are acquired once they are translated
80
82
and stored in the pofile.
@@ -88,6 +90,10 @@ def cli(pofile, source, target, tier, public_key, private_key, sandbox, debug,
88
90
89
91
honyaku german.po de fr --tier pro
90
92
93
+ Run with --accept-all to automatically approve all translations:
94
+
95
+ honyaku german.po de fr --accept-all
96
+
91
97
"""
92
98
93
99
# to make sure that the security issue is patched properly, we do that
@@ -131,50 +137,63 @@ def fetch_translations(order_id):
131
137
if not is_order_complete (order_id ):
132
138
reviewable = fetch_order_jobs (order_id )['jobs_reviewable' ]
133
139
134
- columns = shutil .get_terminal_size ((80 , 20 )).columns
135
- single_hr = "-" * columns
136
- double_hr = "=" * columns
137
-
138
- for job_id in reviewable :
139
- job = gengo .getTranslationJob (id = job_id )['response' ]['job' ]
140
- print (double_hr )
141
- print (job ['body_src' ])
142
- print (single_hr )
143
- print (job ['body_tgt' ])
144
- print (single_hr )
145
-
146
- answer = None
147
- while answer not in ('a' , 'r' , 'q' ):
148
-
149
- answer = input (
150
- "(a)ccept translation, (r)evise it or (q)uit? " )
151
-
152
- answer = answer [0 ]
153
-
154
- if answer == 'q' :
155
- return
156
-
157
- if answer == 'a' :
140
+ if accept_all :
141
+ # Automatically accept all translations
142
+ print (f"Auto-accepting { len (reviewable )} translations..." )
143
+ for job_id in reviewable :
158
144
gengo .updateTranslationJob (
159
145
id = job_id ,
160
146
action = {
161
147
'action' : 'approve' ,
162
148
}
163
149
)
164
- print ("" )
165
- continue
166
-
167
- if answer == 'r' :
168
- comment = input ("comment for the translator: " )
169
- gengo .updateTranslationJob (
170
- id = job_id ,
171
- action = {
172
- 'action' : 'revise' ,
173
- 'comment' : comment
174
- }
175
- )
176
- print ("" )
177
- continue
150
+ print (f"All { len (reviewable )} translations accepted." )
151
+ else :
152
+ # Interactive review process
153
+ columns = shutil .get_terminal_size ((80 , 20 )).columns
154
+ single_hr = "-" * columns
155
+ double_hr = "=" * columns
156
+
157
+ for job_id in reviewable :
158
+ job = gengo .getTranslationJob (id = job_id )['response' ]['job' ]
159
+ print (double_hr )
160
+ print (job ['body_src' ])
161
+ print (single_hr )
162
+ print (job ['body_tgt' ])
163
+ print (single_hr )
164
+
165
+ answer = None
166
+ while answer not in ('a' , 'r' , 'q' ):
167
+
168
+ answer = input (
169
+ "(a)ccept translation, (r)evise it or (q)uit? " )
170
+
171
+ answer = answer [0 ]
172
+
173
+ if answer == 'q' :
174
+ return
175
+
176
+ if answer == 'a' :
177
+ gengo .updateTranslationJob (
178
+ id = job_id ,
179
+ action = {
180
+ 'action' : 'approve' ,
181
+ }
182
+ )
183
+ print ("" )
184
+ continue
185
+
186
+ if answer == 'r' :
187
+ comment = input ("comment for the translator: " )
188
+ gengo .updateTranslationJob (
189
+ id = job_id ,
190
+ action = {
191
+ 'action' : 'revise' ,
192
+ 'comment' : comment
193
+ }
194
+ )
195
+ print ("" )
196
+ continue
178
197
179
198
if not is_order_complete (order_id ):
180
199
print ("Order is not yet complete" )
0 commit comments