General Introduction
Doc2XAPITranslate is a powerful full-text document translation tool designed for quickly translating English PDF or Markdown papers into Chinese documents. The tool supports multiple translators, including DeepSeek, OpenAI, Ollama, Google Translate, DeepL and DeeLX, to ensure the accuracy and diversity of translations.Doc2XAPITranslate is able to preserve formulas, tables and images formatting in the original text, providing high quality translation results. Users can convert documents to Markdown or Word format with simple operations for subsequent editing and use.
Function List
- Multi-translator support: A variety of built-in translators such as DeepSeek, OpenAI, Ollama, Google Translate, DeepL and DeeLX.
- multithreaded translation: Support multi-threaded translation to improve translation speed and efficiency.
- Format retention: Preserve formulas, tables and graphic formats in the original text to ensure the integrity of the translation result.
- Multiple output formats: Supports output of translation results to Markdown or Word format.
- Customized Translator: Users can customize the translator to meet specific needs.
- GUI interface: Provides a friendly graphical user interface for user-friendly operation.
- CLI support: Supports command line interface operation for advanced users and automated processes.
Using Help
Installation process
- Windows (computer)::
- Download and install Pandoc.
- Install by entering the following command in Powershell:
shell
winget install --source winget --exact --id JohnMacFarlane.Pandoc
- MacOS::
- Run the following command in a terminal to install Pandoc:
shell
brew install pandoc
- Run the following command in a terminal to install Pandoc:
- Ubuntu/Debian::
- Run the following command in a terminal to install Pandoc:
shell
sudo apt install pandoc
- Run the following command in a terminal to install Pandoc:
- Arch/Manjaro::
- Run the following command in a terminal to install Pandoc:
shell
sudo pacman -S pandoc-cli
- Run the following command in a terminal to install Pandoc:
Usage Process
- Run the GUI program::
- Download the precompiled program, unzip it and run it.
- Import the Markdown or PDF file, select the translator and translation settings, and click Start Translation.
- When the translation is complete, select the output format (Markdown or Word) and save the file.
- Running a CLI program::
- Clone the current repository:
shell
git clone https://github.com/NoEdgeAI/Doc2XAPITranslate.git
cd Doc2XAPITranslate
- Create and activate a virtual environment:
shell
conda create -n translate python=3.12
conda activate translate
- Install the dependencies:
shell
pip install -r requirements.txt
- Run the program:
shell
python Main.py
- Clone the current repository:
Customized Translator
- Define the translation function::
def translate(text: str, prev_text: str, next_text: str) -> str.
try.
return "This is an example!"
except Exception as e: print(f "Error: {e}")
print(f "Error: {e}")
return text
- Using a Custom Translator::
from MD_Translate import Process_MD
file_path = "path/to/your/md/file.md"
threads = 10
Process_MD(md_file=file_path, translate=translate, thread=threads)