1

I have been using https://translate.google.com/ to translate Spanish PDFs & Word Documents to English.

Is there a Restful API (or other method) to translate a document from Spanish to English while preserving the formatting of the document?

I know I can extract the text then translate it using Google APIs but I would loose the formatting.

1 Answers1

0

You could run this code in Python:

import goslate
big_files = ['lenin.txt', 'liga.txt']
gs = goslate.Goslate()

translation = []
for big_file in big_files:
    with open(big_file, 'r') as f:
        translated_lines = []
        for line in f:
            translated_line = gs.translate(line, "en")
            translated_lines.append(translated_line)

        translation.append('\n'.join(translated_lines))

You set in the directory where the docs you want to translate are, and then, in big_files you write the name of each document.

YakovL
  • 7,557
  • 12
  • 62
  • 102
anitasp
  • 577
  • 4
  • 13
  • 35