Skip to main content

Translate math-heavy papers

Project description

MathTranslate

English | 简体中文

This is a project to provide translation of scientific papers with heavy math symbols from any language to any language while keeping the math symbols unchanged. In most translation softwares you wouldn't be able to keep equations and it would annoy you.

The main work of this project is to translate LaTex files based on Google Translate in plain text, and finally realize the translation of pdf.

Here's an example of what you get finally.

Although it is currently a small project, we are aware that this project has received much more attention that we expected. We are planning more developments for better user experience.

Releases

Mar 24, 2023

We add the ability to directly translate arxiv papers.

Mar 21, 2023

We add tencent translation option for users with IP in China mainland.

Mar 16, 2023

We are now supporting all operating systems! Now you can install simply by pip install --upgrade mathtranslate.

Requirements

  1. Python3 and pip. Anaconda is recommended.
  2. (For users with IP in Mainland China): Tencent Translation API account. After registration, you can get the secret ID and secret key in Tencent Console. Tencent Translate is the translation API with the highest free quota to our knowledge besides Google Translate, with a free quota of 5 million characters per month, and no fee will be deducted if there is no manual recharge (that is, there is no need to worry about misuse).

Installation

pip install --upgrade mathtranslate

Usage

  1. Prepare or generate a tex file. You can get the tex file by the following two ways:
    • For most arxiv papers, you can download the latex source code (Download - Other formats - Source). If the file you downloaded has no suffix, in most cases it is in .tar format, you may need to add the suffix manually. After decompression you can get a latex project, and then you can translate the .tex files in it.
    • Use mathpix to take a screenshot of the part you want to translate and save in a file. You can screenshot many connected paragraphs at one time, or combine multiple converted latex code into one file. Unfortunately, it's not completely free. Currently mathpix offers 100 screenshots for free (an edu email is required for registration) or 5000 screenshots for $5 per month.
  2. (Tencent Translate API users) run translate_tex --setkey to store the API ID and key.
  3. Translate the tex file by translate_tex input.tex -o output.tex.
  4. Compile your tex file. You can compile it with the texlive command xelatex output.tex. For Chinese you need the xeCJK package. If it is a downloaded arxiv project, we recommend compressing all files into a zip file and uploading it to overleaf for online compilation. Note, you need to set the XeLatex compiler in Menu - Compiler, otherwise it cannot handle other languages.
  5. You can change the default settings of the translation language and engine through the command line arguments -engine, -from, -to. For example translate_tex -engine tencent input.tex -o output.tex. You can also permanently change the setting via translate_tex --setdefault. You can see more details with translate_tex --help.

Examples

In the example directory, you can see main.txt which is the mathpix output of a part of paper.pdf. Run translate_tex main.txt and you will get the main.tex and main.pdf. translated.png is what you should expect to see in the main.pdf.

Known Issues

  1. If \begin{env} \end{env} is reset with \newcommand in latex, it will not be translated correctly.
  2. There is a small probability to get something like "XMATHX_1_2" or wrong formula during translation. The accuracy rate of Tencent translation is slightly lower than that of Google translation.

Further developments

  1. Automatically extract images from pdf, process images in a batch and output a single translated pdf by one click!
  2. Reduce the number of mathpix requests by open-source techniques.
  3. A more user-friendly interface.

If you have any questions or have interests in making contributions, please contact me by susyustc@gmail.com or joining QQ group 288646946.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mathtranslate-2.1.3.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

mathtranslate-2.1.3-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file mathtranslate-2.1.3.tar.gz.

File metadata

  • Download URL: mathtranslate-2.1.3.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for mathtranslate-2.1.3.tar.gz
Algorithm Hash digest
SHA256 c4a39173aff2bf8ecca29454b3d8215316876a159b678c89428ea5307d2f368c
MD5 62fb95f4fc77cb750698e10c3c12668e
BLAKE2b-256 ba6e1c03ea6b6bff18230efbf5d0c527d79f062856fa8cf2919ce8dd90366ffd

See more details on using hashes here.

File details

Details for the file mathtranslate-2.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for mathtranslate-2.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 28d94582754d98b314d0acf77b423de020f8eb3cfc1b56b78e2ed8ce29a6329b
MD5 0f9c268cd8e53b2830d851e51f0c293c
BLAKE2b-256 d4cc0c032d289783705e5f0c4b4de31ecbe1383f6cbb1299b37cdc05566b98db

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page