ZMP Markdown Translator
A high-performance markdown translator that supports multiple languages and preserves markdown formatting. Uses OpenAI's GPT models for translation.
Features
- Translates entire directories of markdown files
- Preserves markdown formatting and structure
- Supports multiple target languages simultaneously
- Handles large files through automatic chunking
- Maintains Docusaurus-compatible directory structures
- Shows real-time progress with colorized output
- Enforces consistent translation rules for technical documentation
Translation Rules
The translator follows strict rules to ensure consistent and accurate translations:
Preserved in English
- Front matter between
---markers (including id, title, sidebar_position) - All section headers (including those with HTML tags)
- All HTML-wrapped headers and subheadings
- Product names (e.g., Cloud Z CP)
- Platform names (e.g., Kubernetes)
- Service names (e.g., Container Management Service)
- Tool names (e.g., Chrome, Gitea)
- Version numbers and technical specifications
- Table headers in markdown tables
- Section IDs in curly braces
Translated to Target Language
- All paragraphs and content text
- Descriptions and explanations
- UI messages and instructions
- List items and bullet points
- Table content (except headers)
- Sentences containing product names (while keeping the names in English)
Consistency Requirements
- No mixed language content within sentences
- Complete translation of all paragraphs
- Preservation of markdown structure and formatting
- Exact maintenance of whitespace and line numbers
Installation
# Using Poetry (recommended)
poetry install
# Or using pip
pip install zmp-md-translator
Usage
Basic Command Structure
zmp-translate \
--source-dir SOURCE_PATH \
--target-dir TARGET_DIR \
--languages LANG_CODES \
--solution SOLUTION_TYPE
Required parameters:
SOURCE_PATH: Path to a markdown file or directory containing markdown filesLANG_CODES: Comma-separated list of target language codesSOLUTION_TYPE: Type of documentation (zcp, apim, or amdp)
Optional parameters:
TARGET_DIR: Target directory for translations (default: "i18n")--model: OpenAI model to use (overrides .env setting)--chunk-size: Maximum chunk size for translation--concurrent: Maximum concurrent requests
Example Usage
# Translate a directory
zmp-translate \
--source-dir "./repo/docs/zcp/v2.0" \
--target-dir "./repo/i18n" \
--languages "ko,ja,zh" \
--solution zcp
# Translate a single file
zmp-translate \
--source-dir "./repo/docs/zcp/v2.0/FAQ.mdx" \
--target-dir "./repo/i18n" \
--languages "ko" \
--solution zcp
Using short options:
# Directory translation
zmp-translate -s "./repo/docs/zcp/v2.0" -t "./repo/i18n" -l "ko,ja,zh" --solution zcp
# Single file translation
zmp-translate -s "./repo/docs/zcp/v2.0/FAQ.mdx" -t "./repo/i18n" -l "ko" --solution zcp
Output Directory Structure
The translator creates a Docusaurus-compatible directory structure:
i18n/
├── ko/
│ └── docusaurus-plugin-content-docs-zcp/
│ └── current/
│ └── v2.0/
│ ├── FAQ.mdx
│ └── ...
├── ja/
│ └── docusaurus-plugin-content-docs-zcp/
│ └── current/
│ └── v2.0/
│ ├── FAQ.mdx
│ └── ...
└── zh/
└── docusaurus-plugin-content-docs-zcp/
└── current/
└── v2.0/
├── FAQ.mdx
└── ...
Supported Language Codes
The following language codes are supported:
| Code | Language |
|---|---|
| ko | Korean |
| fr | French |
| ja | Japanese |
| es | Spanish |
| de | German |
| zh | Chinese |
| ru | Russian |
| it | Italian |
| pt | Portuguese |
| ar | Arabic |
Environment Configuration
Create a .env file in your project root:
# OpenAI Configuration
OPENAI_API_KEY=your-api-key-here
OPENAI_MODEL=your-model-here
# Performance Settings
MAX_CHUNK_SIZE=4000
MAX_CONCURRENT_REQUESTS=5
Development
# Install dependencies
poetry install
# Run tests
poetry run test
# Run with watch mode (development)
poetry run watch
License
This project is distributed under the MIT License. See the LICENSE file for more information.
Metadata
Release files for zmp-md-translator 0.2.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| zmp_md_translator-0.2.8.tar.gz | 18.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zmp_md_translator-0.2.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.6 kB
Release files / zmp_md_translator-0.2.8.tar.gz
| Download URL | zmp_md_translator-0.2.8.tar.gz |
|---|---|
| Size | 18.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f03a589832ecb4b6e40d1e4cd534239a57bf6f3e8d03721908a4df1c26e510b4
|
|
BLAKE2b-256 checksum How to use checksums |
8256b07951bf8f28aaab8652890367e69eb5b04cd6c93f4c56af84a47db423fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.13.3 Darwin/24.5.0
|
Release files / zmp_md_translator-0.2.8-py3-none-any.whl
| Download URL | zmp_md_translator-0.2.8-py3-none-any.whl |
|---|---|
| Size | 19.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf6be9ae4312595a80321aa229ced3a19b29cba7b508df069d5187616ac45bd4
|
|
BLAKE2b-256 checksum How to use checksums |
4606a5f4b9c73631f1def7c455d3767b8af551e0bdd4372c9faf274125d17a46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.13.3 Darwin/24.5.0
|