Lingo.dev + .json-dictionary

Lingo.dev CLI translates JSON files where each translatable string contains multiple locale keys in a single object. Unlike standard JSON format that separates locales into different files, json-dictionary stores all translations together with locale-specific keys like {"en": "Hello", "es": "Hola"}.

Quick Setup

Create an i18n.json configuration file:

{
  "locale": {
    "source": "en", 
    "targets": ["es", "fr", "de"]
  },
  "buckets": {
    "json-dictionary": {
      "include": ["content/pages.json"]
    }
  }
}

File Structure

json-dictionary format stores translations as nested objects with locale keys:

{
  "title": {
    "en": "Welcome to our site",
    "es": "Bienvenido a nuestro sitio"
  },
  "navigation": {
    "home": {
      "en": "Home",
      "es": "Inicio"
    },
    "about": {
      "en": "About Us", 
      "es": "Acerca de nosotros"
    }
  },
  "staticValue": "This won't be translated",
  "pages": [
    {
      "title": {
        "en": "Page One",
        "es": "Página Uno"
      }
    }
  ]
}

Translate Everything

npx lingo.dev@latest i18n

The CLI automatically:

  • Extracts only translatable objects (those with locale keys)
  • Preserves non-translatable values unchanged
  • Adds target locale keys alongside existing ones
  • Maintains source locale key ordering (source first, others alphabetically)

Key Behavior

Translatable Detection: Only objects containing your source locale key are considered translatable. Plain strings, numbers, booleans, and objects without locale keys remain unchanged.

Key Ordering: When adding translations, the source locale appears first, followed by other locales in alphabetical order:

{
  "message": {
    "en": "Original text",
    "de": "Deutscher Text", 
    "es": "Texto en español",
    "fr": "Texte français"
  }
}

Nested Support: Works with deeply nested structures and arrays containing translatable objects.

Advanced Configuration

Exclude Files

"json-dictionary": {
  "include": ["content/*.json"],
  "exclude": ["content/config.json"]
}