Translate YAML Files for Backend Frameworks
Simplify localization for Ruby on Rails, Laravel, and other backend frameworks with Lingo.dev's powerful YAML translation capabilities.
Quick Setup
Create an i18n.json
configuration file in your project root:
{
"version": 1,
"locale": {
"source": "en",
"targets": ["ja", "ko", "zh"]
},
"buckets": {
"yaml": {
"include": ["locales/[locale].yml"]
}
}
}
This configuration:
- Sets English as your source language
- Targets Japanese, Korean, and Chinese translations
- Looks for files in the
locales
folder with locale-based naming (e.g.,en.yml
,ja.yml
)
One Command Translation
Translate all your YAML files with a single command:
npx lingo.dev@latest i18n
This automatically:
- Reads your source YAML files
- Identifies new or modified content
- Translates only what's changed
- Creates or updates target language files with identical structure
Framework-Specific Features
Ruby on Rails Support with Root Keys
For frameworks like Rails that use locale-based root keys, use the specialized yaml-root-key
bucket type:
{
"version": 1,
"locale": {
"source": "en",
"targets": ["fr", "de", "it"]
},
"buckets": {
"yaml-root-key": {
"include": ["locales/[locale].yml"]
}
}
}
This handles files with locale namespacing:
en:
greeting: "Hello"
farewell: "Goodbye"
fr:
greeting: "Bonjour"
farewell: "Au revoir"
Smart YAML Handling
Complex Structure Support
Lingo.dev preserves all YAML formatting and structure:
Nested Hierarchies
navigation:
home: Home
about:
team: Our Team
mission: Our Mission
Multi-line Text
long_text: |
This is a long piece of text
that spans multiple lines.
Lingo.dev will translate it
while maintaining the format.
Variable Placeholders
welcome: "Welcome, %{name}!"
count_message: "You have %{count} new messages."
Advanced Configuration Options
Protect Technical Content with Key Locking
Prevent translation of specific keys:
"yaml": {
"include": ["locales/[locale].yml"],
"lockedKeys": [
"system/version",
"config/api_url",
"branding/name"
]
}
Key locking features:
- Uses forward slash (
/
) as the separator for nested keys - Works with keys containing dots (e.g.,
config/api.url
) - Compatible with nested objects and array elements
- Supports both regular YAML and YAML with root key formats
For more details, see the Key Locking documentation.
Why Developers Choose YAML Translation
- Framework Compatibility: Perfect for Rails, Laravel, and other backend frameworks
- Structure Preservation: Maintains your exact YAML hierarchy and formatting
- Format Flexibility: Handles both flat and deeply nested YAML structures
- Incremental Updates: Only translates what's changed, saving time and resources
- Multi-line Support: Preserves complex text formatting across languages
By integrating Lingo.dev into your development workflow, you get powerful AI-driven translations while maintaining complete control over your localization files and process.