Crates.io | mdbook-translator |
lib.rs | mdbook-translator |
version | 0.1.3 |
created_at | 2025-09-06 12:03:23.632783+00 |
updated_at | 2025-09-06 17:29:47.978355+00 |
description | A translation preprocessor plugin for mdBook that automatically translates documents using the DeepSeek API |
homepage | https://github.com/BUB97/mdbook-translator |
repository | |
max_upload_size | |
id | 1826997 |
size | 107,923 |
A translation preprocessor plugin for mdBook that automatically translates Markdown documents using the DeepSeek API.
# Clone the project
git clone <repository-url>
cd mdbook-translator
# Build the project
cargo build --release
# Install to system path
cargo install --path .
cargo install mdbook-translator
Visit DeepSeek Official Website to get your API key and set the environment variable:
export DEEPSEEK_API_KEY="your-api-key-here"
Add the following configuration to your mdBook project's book.toml
file:
[book]
title = "Your Book Title"
authors = ["Author Name"]
[build]
build-dir = "book-zh" # Optional: specify output directory
[preprocessor.translator]
command = "mdbook-translator"
language = "Chinese" # Target translation language
prompt = "Please keep technical terms like Send, Future, Futures in Rust untranslated" # Optional: custom translation prompt
# support configure a proxy like:
proxy = "http://127.0.0.1:8099" # Optional: HTTP proxy URL
language
: Target translation language (e.g., "Chinese", "Japanese", "Korean", etc.)prompt
: Optional custom translation prompt to guide translation behaviorproxy
: Optional HTTP proxy URLbuild-dir
: Optional output directory, defaults to "book"# Run in your mdBook project directory
mdbook build
The plugin will automatically:
If you need to retranslate, you can delete the cache file:
rm deepseek_cache.json
The plugin outputs debug information to standard error output, including cache hit information.
DEEPSEEK_API_KEY
environment variablemdbook
: mdBook core libraryreqwest
: HTTP client for API callsserde_json
: JSON serialization/deserializationsha2
: Hash calculation for cache key generationanyhow
: Error handlingclap
: Command line argument parsingtoml
: TOML configuration file parsingRefer to the async-book
project configuration:
[book]
title = "Asynchronous Programming in Rust"
authors = ["Taylor Cramer", "Nicholas Cameron", "Open source contributors"]
[build]
preprocessor = ["mdbook-translator"]
build-dir = "book-zh"
[preprocessor.translator]
command = "mdbook-translator"
language = "Chinese"
prompt = "Please keep technical terms like Send, Future, Futures in Rust untranslated"
Welcome to submit Issues and Pull Requests!