TransWikia.com

How can I translate to English a TeX document without losing compilability?

TeX - LaTeX Asked by bhathiya-perera on February 10, 2021

Is there any way I can translate comments and non-commands from a different language to English ?

I tried :

  1. Google Search

    No results

  2. Using http://translate.google.com/ to translate File pasted as text

    File : http://phobos.xtec.cat/jqueralt/IMG/tex/packtpub.tex

    Obviously will not compile

  3. Using http://translate.google.com/ to translate File drag-and-drop

    I got the following result:

    Sorry, the page you requested contains a file type (application/octet-stream) we are unable to translate.

3 Answers

Try this:

  1. Save the file with a .txt extension. This will avoid the error "Sorry, the page you requested contains a file type (application/octet-stream) we are unable to translate."

  2. Change all backslashes using your editor to ==zz. This results to words that Google cannot translate and hence it leaves as is. This works well for single commands.

Use the same strategy for any other items you do not want Google to translate. For example you can search and replace all { with BACKSLASHSH. This way you will not get any unwanted spaces. Just use words or mixtures of words and numbers that Google will not have a translation. For example it will translate figure but not FIGORE.

  1. Translate text.

  2. Search and replace again with your editor all ==zz to backslashes and other strings you have protected.

If you familiar with coding in a language such as Perl, Python or Lua you can fence the commands in a more robust way, by providing a small script to do all the search and replace. For example you could change all:

   begin{figure}[htbp]

to a hash key such as 12345678 to protect it from translation, and then reverse it back again once you have the translation.

Sadly Google does not provide a free web API any longer, otherwise you could have done all this automatically via LuaTeX and the socket library or similar.

Answered by Yiannis Lazarides on February 10, 2021

Here is a tool gtexfix which I wrote which does the replacements of LaTeX commands and math formulas by tokens automatically. It helps to translate safely .tex documents with Google Translate without breaking the LaTeX.

Answered by Dmitry Gulevich on February 10, 2021

You can use https://www.deepl.com You can give it tex file. DeepL keeps formating and markup (although, not always).

Answered by Rishat on February 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP