AI Translation
Doom provides intelligent AI-powered translation for documentation, automatically translating content while preserving MDX formatting, code blocks, technical terms, and links. The translation system uses Azure OpenAI for high-quality, context-aware translations.Quick Start
Translate documentation from English to Chinese:docs/en/ to docs/zh/.
How It Works
The translation process:- Scans source files matching glob patterns
- Checks SHA hashes to skip unchanged files
- Extracts frontmatter and content separately
- Preserves links, code blocks, and MDX components
- Translates using Azure OpenAI with custom prompts
- Restores formatting and special syntax
- Writes translated files with updated SHA
Translation uses intelligent chunking for large files and includes automatic retry logic for rate limits.
Configuration
Environment Variables
Configure Azure OpenAI credentials:Config File
Customize translation behavior indoom.config.yml:
Command Usage
Required Options
Glob patterns for files to translate (relative to source language directory)
Optional Parameters
Root directory of the documentation (default: current directory)
Source language code. Supported:
en, zh, ru, ja, ko, es, fr, de, pt, itTarget language code. Same supported languages as source.
Copy relative asset files to target directory instead of following links
Force re-translation even if source SHA matches (ignores hash equality check)
Example Commands
Supported Languages
The translation system supports these language codes:English
enChinese
zhRussian
ruJapanese
jaKorean
koSpanish
esFrench
frGerman
dePortuguese
ptItalian
itTerminology Management
Define custom terminology translations for consistent technical terms across languages.Supported Term Languages
Terminology management is available for:en, zh, ru
Terms File
Create a terms file (format depends on your implementation):- Detects relevant terms in source content
- Provides them to the AI as translation glossary
- Ensures consistent translation across documents
Frontmatter Handling
Automatic Translation
Certain frontmatter fields are automatically translated:Custom Prompts
Add page-specific translation instructions:Custom instructions for translating this specific page
Skip automatic translation for this page
Source SHA
The system tracks content changes using SHA hashes:Content Preservation
The translation system intelligently preserves:Links
All link formats remain unchanged:Code Blocks
Code and syntax are never translated:MDX Components
Special Comments
Preserved comments:Heading Anchors
Custom heading IDs are preserved:{#getting-started} remains unchanged in translation.
Technical Terms
Preserved by default:- Product names: Kubernetes, Docker, React, etc.
- Technical terms: API, REST, JSON, YAML, CLI, etc.
- Code identifiers: Variable names, function names
- URLs and email addresses
Chunking for Large Files
Files larger than 60KB are automatically split into chunks:Rate Limiting
Built-in rate limiting prevents API throttling:- Initial retry: 60 seconds
- Max retries: 15
- Increasing delay on subsequent retries
Special Modes
Full Sync Mode
Using glob pattern* enables full sync:
- Translates all source files
- Removes target files without matching source
- Ensures target directory exactly matches source structure
- Shows warning about file removal
Copy-Only Directories
Certain directories are copied instead of translated:- Update
sourceSHAin frontmatter - Copy content exactly without translation
- Maintain structure and formatting
Advanced Usage
Custom System Prompt
The default prompt is highly optimized, but you can customize:sourceLang- Source language nametargetLang- Target language nameterms- Relevant terminology listtitleTranslationPrompt- Pre-defined title translationsuserPrompt- Custom user instructionsadditionalPrompts- Page-specific promptsisChunk- Whether this is part of a larger document
Title Translation Map
Pre-define translations for common titles:Internal Routes
Exclude internal/draft pages from translation:Asset Handling
Link Mode (Default)
By default, asset paths are preserved:Copy Mode
With--copy, assets are duplicated:
Translation Quality
The system ensures quality through:Troubleshooting
API Authentication Error
Solution
Solution
Verify your Azure OpenAI credentials:
Rate Limit Errors
Solution
Solution
The system automatically retries, but if errors persist:
- Reduce concurrency (modify source if needed)
- Translate in smaller batches:
- Wait for rate limit reset
- Check your Azure OpenAI quota
Missing Translations
Solution
Solution
If files aren’t being translated:
- Verify glob patterns match files:
- Check for
disableAutoTranslation: truein frontmatter - Ensure files aren’t in
internalRoutes - Look for errors in console output
Formatting Issues
Solution
Solution
If translated files have formatting problems:
- Check source file for valid MDX syntax
- Verify code blocks are properly closed
- Ensure MDX components are valid
- Use
--forceto re-translate after fixing source - Review the systemPrompt for formatting instructions
Best Practices
Start Small
Test translation on a few files first to verify quality and settings.
Use Terminology
Define key terms upfront for consistency across all translations.
Review Translations
Always review AI translations, especially for technical content.
Leverage SHA Tracking
Use SHA to only review translations of changed content.
Batch by Section
Translate related content together for better context.
Version Control
Commit translations separately from source changes for easier review.
Integration Examples
CI/CD Pipeline
NPM Scripts
Related Features
Auto Sidebar
Generate multilingual navigation automatically
PDF Export
Export translated documentation to PDF