Browse Source

Improve calculation of the translator's approximate time

Calculate the approximate time for the translator based on a
new formula [(items_count * (wait_time + avg_msg)) - wait_time]
instead of using only the number of entries in the PO file.
doc-issue-template
MrS0m30n3 7 years ago
parent
commit
968f197ee4
1 changed files with 10 additions and 4 deletions
  1. 14
      devscripts/check-translation.py

14
devscripts/check-translation.py

@ -197,9 +197,6 @@ def main(args):
# Init translator only if the '--no-translate' flag is NOT set
translator = None
if not args.no_translate:
eta = timedelta(seconds=len(pot_file) * WTIME)
pinfo("Approximate time to check translations online: {}".format(eta))
translator = google_translate.GoogleTranslator(timeout=5.0, retries=2, wait_time=WTIME)
# Set source language for GoogleTranslator
@ -230,7 +227,16 @@ def main(args):
else:
further_analysis.append(entry)
if translator is not None:
if translator is not None and further_analysis:
# eta = (items_to_analyze * (WTIME + avg_ms)) - WTIME
# We subtract WTIME at the end because there is no wait for the last item on the list
# avg_msg = 200ms
eta_seconds = (len(further_analysis) * (WTIME + 0.2)) - WTIME
eta_seconds = int(round(eta_seconds))
eta = timedelta(seconds=eta_seconds)
pinfo("Approximate time to check translations online: {}".format(eta))
# Pass translations as a list since GoogleTranslator can handle them
words_dict = translator.get_info_dict([entry.msgstr for entry in further_analysis], "en", src_lang)

Loading…
Cancel
Save