Internationalization
Doom provides built-in support for multilingual documentation, making it easy to maintain content in multiple languages with automatic translation tools.Language Configuration
Configure supported languages in yourdoom.config.yml:
- Multilingual
- Single Language
doom.config.yml
en) and Chinese (zh) out of the box.Directory Structure
Organize content by language using subdirectories:Static Assets Organization
Store language-specific images and assets in separate directories:Translation Strings for Components
For reusable components that need multilingual text, use thei18n.json file:
Create i18n.json
docs/i18n.json
Use in React Components
Access translations using theuseI18n hook:
shared/Welcome.tsx
Use in MDX Files
Access translations directly in MDX:welcome.mdx
The
useI18n hook automatically returns text for the current language based on the active route.AI-Powered Translation
Doom includes built-in AI translation using thetranslate command.
Basic Usage
- Single File
- Multiple Files
- All Files
Translate a specific file:
Translation Configuration
Customize the AI translation behavior:doom.config.yml
Translation Variables
The system prompt has access to these EJS variables:Source language name (e.g., “中文”, “English”)
Target language name (e.g., “English”, “中文”)
Custom user-defined prompt from configuration
Document-specific prompts from frontmatter
Auto-generated terminology guidelines
Auto-generated title mapping guidance
Document-Specific Translation
Control translation behavior per document using frontmatter:Force Retranslation
Bypass hash checks to force retranslation:Doom tracks content hashes to avoid retranslating unchanged files. Use
--force to override this optimization.Language Filtering
Build or serve specific languages only:- Include Languages
- Exclude Languages
Build only specific languages:
Language Redirection
Control how users are redirected based on browser language:Redirect to the closest match for
navigator.languageonly-default-lang
Only redirect when accessing root without a language prefix
never
Never automatically redirect users
Terminology Management
Define consistent terminology across languages:Using the Term Component
Configure Terms
Terms are typically configured in deployment overrides. See the configuration documentation for details on setting up custom terms.Display Terminology Table
Show all defined terms:Frontmatter Translation
Frontmatter fields are handled specially during translation:Translation Rules
Translation Rules
title: Always translateddescription: Always translated- Other fields: Preserved as-is
- Structure: Maintained exactly
Best Practices
Directory structure
Directory structure
- Keep language directories perfectly synchronized
- Use identical filenames across languages
- Maintain the same folder hierarchy
- Store language-specific assets in separate directories
Translation workflow
Translation workflow
- Write content in your primary language (e.g., Chinese)
- Create the target language directory structure
- Run the translation command
- Review and refine AI-generated translations
- Commit both language versions together
Component localization
Component localization
- Extract all user-facing strings to
i18n.json - Use
useI18nhook consistently - Avoid hardcoded strings in components
- Test components in all supported languages
Content guidelines
Content guidelines
- Write clear, translatable source content
- Avoid idioms and culturally-specific references
- Use consistent terminology
- Keep sentences concise for easier translation
- Document translation conventions in your style guide
Translation Workflow Example
Complete workflow for adding multilingual support:Troubleshooting
Routes not matching across languages
Routes not matching across languages
Problem: Links break when switching languages.Solution: Ensure directory structure and filenames are identical:
Translation quality issues
Translation quality issues
Problem: AI translations are inaccurate.Solution:
- Refine the
systemPromptin configuration - Add document-specific
additionalPrompts - Use terminology definitions
- Review and manually edit translations
Component text not translating
Component text not translating
Problem: Component strings show in wrong language.Solution:
- Verify
i18n.jsoncontains all required keys - Check
useI18nhook is used correctly - Ensure no hardcoded strings in components
Advanced: Automated Translation Tool
If using Doom’s automated translation tools, you don’t need to manually maintain identical directory structures—the tool handles this automatically.
- Creates target language directory structure
- Maintains file organization
- Preserves links and references
- Tracks translation status with content hashes
Further Reading
- Project Structure - Learn about directory organization
- Markdown & MDX - Understand content formatting
- Configuration - Explore translation configuration options