Lingo.dev + .jsonc (JSON with Comments)
Lingo.dev CLI translates JSONC (JSON with Comments) files, supporting all standard JSON features plus comments and trailing commas. The CLI extracts comments as translation hints, preserves exact formatting, handles nested structures intelligently, and processes only modified content for cost efficiency.
Quick Setup
Create an i18n.json
configuration file:
{
"locale": {
"source": "en",
"targets": ["es", "fr", "de"]
},
"buckets": {
"jsonc": {
"include": ["locales/[locale].jsonc"]
}
}
}
Reminder: [locale]
is a placeholder that should remain in the config literally, as it's replaced with the actual locale during CLI run.
Translate Everything
npx lingo.dev@latest i18n
Automatically processes nested structures, extracts comments as translation hints, and updates only changed content.
Comment-Based Translation Hints
JSONC's key advantage is using comments to provide translation context:
{
// This comment provides context for the greeting
"greeting": "Hello, world!",
"button": "Click me" /* This explains the button's purpose */,
/*
* Multi-line comment for complex context
* explaining cultural nuances
*/
"welcome": "Welcome to our app"
}
Comments are automatically extracted as hints to improve translation quality and provide context to AI translators.
Smart Structure Preservation
Maintains complex hierarchies and supports trailing commas:
{
"nav": {
"home": "Home", // Navigation item
"about": {
"team": "Our Team" // Nested navigation
},
},
"items": {
"one": "{{count}} item",
"other": "{{count}} items", // Pluralization support
},
}
Advanced Configuration
Exclude Files
"jsonc": {
"include": ["locales/[locale]/*.jsonc"],
"exclude": ["locales/[locale]/config.jsonc"]
}
Lock Technical Keys
"jsonc": {
"lockedKeys": ["app/version", "settings/apiKey"]
}
Use forward slash (/
) for nested key paths or asterisk (*
) to match multiple keys paths.