Do you need to translate your work in LaTeX into a foreign language? Don't have the time or skills to do it? Why not let a computer do it for you?
Machine translation has made huge progress and the text produced is quite good.
However automatic translators don't like mathematics and LaTeX file. We provide here a tool to hide mathematics to the machine so that you can translate any scientific text from one language to another.
These tools have been used to translate the book Python au lycée to Python in high school, more than 200 pages, in 15 workdays. See GitHub Exo7.
-
Your original LaTeX file,
-
a Python3 installation and all the Python files you will find in the
bin/
directory, -
and a translator like DeepL Translator or Google Translate.
-
Use
python3 latextotext.py toto.tex
to transform a LaTeX file to a text filetoto.txt
. You will get an additionnal dictionnarytoto.dic
. -
Don't panic if you see lots of tags
€1234€
, they replace maths and LaTeX commands! -
Use automatic translation on the text file, I recommend DeepL Translator, save the file in your target langage as
new_toto.txt
. -
Recover your LaTeX file with
python3 texttolatex.py new_toto.txt toto.dic
, you will get a filenew_toto.tex
in your target langage with your original maths. -
You certainly need to check and correct the translation.
- Start from a file
maths.tex
written in French:
...
Soient $f$ et $g$ deux fonctions continues de $\mathbf{R}$ vers $\mathbf{C}$.
...
-
Execute
python3 latextotext.py maths.tex
. -
You will get a file
maths.txt
:
...
Soient €0€ et €1€ deux fonctions continues de €2€ vers €3€.
...
- And a file
maths.dic
:
0: $f$
1: $g$
2: $\mathbf{R}$
3: $\mathbf{C}$
- Translate the file
maths.txt
to English using DeepL and name the translationnew_math.txt
:
...
Let be €0€ and €1€ two continuous functions from €2€ to €3€.
...
- Execute
python3 texttolatex.py new_maths.txt maths.dic
to get a filenew_maths.tex
:
...
Let be $f$ and $g$ two continuous functions from $\mathbf{R}$ to $\mathbf{C}$.
...
- Adjust the translation by hand:
...
Let $f$ and $g$ be two continuous functions from $\mathbf{R}$ to $\mathbf{C}$.
...