Translations & i18n
Translations & i18n
This guide explains how to add and manage translations for the FileBrowser Quantum documentation using Hugo’s multilingual mode.
Overview
The documentation supports multiple languages using Hugo’s i18n (internationalization) framework. This allows users to read the documentation in their preferred language.
Current Language Support
- English (en) - Default language
- German (de) - Available
- French (fr) - Available
- Portuguese (pt) - Available
How i18n Works in Hugo
Hugo’s multilingual framework supports:
- Single-host configuration - All languages on one domain
- Multi-host configuration - Each language on its own domain
- Content translation - Translate pages and content
- String translation - Translate UI elements and messages
- Localization - Dates, numbers, currencies, percentages
- Menu translation - Localized navigation menus
Content Translation Methods
Method 1: Translation by File Name
Create separate files for each language with language codes as suffixes:
Example:
Method 2: Translation by Content Directory
Organize content in language-specific directories:
Method 3: Translation Key (Advanced)
Use translationKey in front matter to link pages regardless of location:
Configuration
Language Configuration
Configure languages in hugo.toml:
| |
Menu Translation
Configure language-specific menus:
String Translation
Translation Files
Store translated strings in i18n/ directory:
Example i18n/en.toml:
Example i18n/de.toml:
Using Translations in Templates
Use the T function to translate strings:
Using Translations in Content
Use Hugo’s built-in i18n function in templates:
Adding a New Language
Step 1: Configure Language
Add the new language to hugo.toml:
Step 2: Create Translation Files
Create i18n/es.toml:
Step 3: Translate Content
Create translated content files:
Step 4: Update Menus
Add language-specific menu entries:
Translation Workflow
For Content Translators
- Choose a page to translate
- Create translated version using one of the methods above
- Update front matter with translated title and description
- Translate content while preserving markdown formatting
- Test the translation using
make dev
For String Translators
- Identify missing strings using
hugo --printI18nWarnings - Add translations to appropriate
i18n/*.tomlfiles - Test translations in the browser
For Maintainers
- Review translations for accuracy and consistency
- Update language configuration when adding new languages
- Maintain translation files and keep them synchronized
Best Practices
Content Translation
- Preserve formatting - Keep markdown structure intact
- Maintain consistency - Use consistent terminology
- Update regularly - Keep translations current with source
- Test thoroughly - Verify all links and references work
String Translation
- Use descriptive keys - Make translation keys meaningful
- Group related strings - Organize translations logically
- Provide context - Add comments for complex translations
- Handle plurals - Use Hugo’s pluralization features
Technical Considerations
- URL structure - Consider localized URLs for better SEO
- Asset management - Handle language-specific assets
- Search functionality - Ensure search works across languages
- Performance - Consider build time with multiple languages
Tools and Resources
Translation Tools
- DeepL API - For automatic translation (see contributing guide)
- Google Translate - For quick reference
- Native speakers - For accurate, natural translations
Hugo i18n Documentation
Theme i18n Support
The Lotus Docs theme supports:
- Automatic language detection
- Language switcher in navigation
- RTL language support
- Localized date/time formatting
Troubleshooting
Common Issues
Missing translations:
| |
Build errors:
- Check language configuration in
hugo.toml - Verify translation file syntax
- Ensure content files have correct front matter
Menu not translating:
- Check language-specific menu configuration
- Verify translation keys in
i18n/*.tomlfiles - Use
Tfunction in menu templates
Getting Help
- Check existing translations - Look at completed language files
- Use translation tools - DeepL API for automatic translation
- Ask community - GitHub discussions for translation help
- Review theme docs - Lotus Docs i18n documentation
Example: Complete Translation
Here’s a complete example of translating a page:
Source (English):
| |
| |
| |