Translate math-heavy papers
Project description
MathTranslate
English | 简体中文
Since google translate cannot be used in China mainland, we will add support of other translation engines as soon as possible.
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. This project is based on the following two tools:
- mathpix: it provides an interface to convert text+equation images to latex code. Unfortunately, it is not totally free. The price can be seen at https://mathpix.com/pricing. In further developments, we will try our best to reduce the number of requests to save your money. (This project itself is 100% free and open-source!)
- google translate
The main work of this project is to translate LaTex files based on Google Translate of plain text, with mathpix combined we can finally translate pdf (or other formats) to 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 16, 2023
We are now supporting all operating systems! Now you can install simply by pip install mathtranslate.
Requirements
- A mathpix account. Unfortunately, it is not totally free. The current price is free for 100 screenshots (requires an educational email in registeration) and $5 per month for 5000 screenshots.
- Python3 and pip.
- texlive (or any other tool to generate pdf from tex). For Chinese you would need CJK package.
Installation
pip install mathtranslate
Usage
- Download mathpix. In the Settings-Formatting, change "Inline math delimiters" and "Block mode delimiters" to "\( ... \)" and "\[ ... \]", respectively.
- Use mathpix to screenshot what you want to translate, copy the output latex code and save in a txt file. Mathpix currently recognizes continuous text (which can be one or more paragraphs). You can also screenshot and copy multiple separated texts and put them in the same txt file, we will automatically identify and merge the paragraphs separated by pictures or pages in the next step.
- Assume the filename you saved in the previous step is
main.txt. Runtranslate_tex.py main.txt. You will get a translated tex filemain.texand a corresponding pdf filemain.pdfin casexelatexis installed on your machine. - Since this project is small, sometimes you need to slightly change the final tex file for compilation.
- The default behavior is translating English into Chinese. If you want to translate from/to other languages, you can use
translate_tex.py --listto find the code of your interested language and then runtranslate_tex.py main.txt -from <code_from> -to <code_to>.
Examples
In the example directory, you can see main.txt which is the mathpix output of a part of paper.pdf. Run translate_tex.py 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.
Further developments
- Automatically extract images from pdf, process images in a batch and output a single translated pdf by one click!
- Reduce the number of mathpix requests by open-source techniques.
- A more user-friendly interface.
If you are interested in making contributions, please contact me by susyustc@gmail.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mathtranslate-1.1.2.tar.gz.
File metadata
- Download URL: mathtranslate-1.1.2.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05805575e18f34419d27dcf90c108ce92428c9abe86a07a6c452e5c71ef9e932
|
|
| MD5 |
bd5dc6ef3d28ed8cab5c981fd24f5ce4
|
|
| BLAKE2b-256 |
999e252aa2226ab0f842ce554643680cc6501612f739364b6d27821fcf6a4a74
|
File details
Details for the file mathtranslate-1.1.2-py3-none-any.whl.
File metadata
- Download URL: mathtranslate-1.1.2-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b0858b5d3269a815441676f98ef6436700450d59c4fa90f260ec73c6e1d7c3d
|
|
| MD5 |
39a693d51ef27270e894f4d7f922560b
|
|
| BLAKE2b-256 |
54e6fef14143e7fbddce408ca2764abcb24576656369b47e2f1a35cdef8b4b32
|