Lingo.dev + .json5 (JSON5)
Lingo.dev CLI translates JSON5 locale files with full support for JSON5 syntax including comments, unquoted keys, trailing commas, and single quotes. The CLI preserves JSON5 formatting and developer-friendly syntax while maintaining framework compatibility and processing only modified content for cost efficiency.
Quick Setup
Create an i18n.json
configuration file:
{
"locale": {
"source": "en",
"targets": ["es", "fr", "de"]
},
"buckets": {
"json5": {
"include": ["locales/[locale].json5"]
}
}
}
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 JSON5 syntax features, preserves comments and formatting, and updates only changed content.
JSON5 Syntax Support
JSON5 extends JSON with developer-friendly syntax:
{
// Comments are supported
title: "Hello, world!", // Line comments work
description: 'Single quotes allowed',
unquoted: 'keys work without quotes',
trailing: 'comma is ok',
/* Block comments
are also supported */
multiline: "This is a \
long string that \
spans multiple lines",
// Hexadecimal numbers
hex_value: 0xDEADBEEF,
positive: +123,
nested: {
key: 'value',
}, // Trailing comma allowed
}
Smart Structure Preservation
Maintains JSON5 syntax and framework conventions:
{
nav: {
home: "Home",
about: {
team: "Our Team"
}
},
items: {
one: "{{count}} item",
other: "{{count}} items"
},
// Configuration stays intact
version: 0x010203
}
Advanced Configuration
Exclude Files
"json5": {
"include": ["locales/[locale]/*.json5"],
"exclude": ["locales/[locale]/config.json5"]
}
Lock Technical Keys
"json5": {
"lockedKeys": ["app/version", "settings/apiKey"]
}
Use forward slash (/
) for nested key paths or asterisk (*
) to match multiple keys paths.
JSON5 vs JSON
JSON5 provides enhanced developer experience while maintaining full JSON compatibility:
- Comments: Document your translations with inline and block comments
- Unquoted Keys: Cleaner syntax without quotes around property names
- Trailing Commas: Easier editing and version control diffs
- Single Quotes: Flexibility in string quoting
- Multiline Strings: Better readability for long text
- Number Formats: Hexadecimal, positive signs, and more
All JSON files are valid JSON5, making migration seamless.