JSON

Languine supports JSON files as a source format with the common requirements for pluralization and interpolation. This format is used in many frameworks like React, Vue, Ruby on Rails, and more.


Setting Up

First, make sure you've got a languine.json config file in your project root. Here's an example:

typescript
{
  "locale": {
    "source": "en",
    "targets": ["sv", "de", "fr"]
  },
  "files": {
    "json": {
      "include": ["locales/[locale].json"]
    }
  }
}

Translating

With your config set, run:

typescript
npx languine@latest translate

When you run this command, Languine will:

  • Load your source JSON file (e.g., locales/en.json)
  • Detect any new or modified translation strings
  • Generate translations for your target languages
  • Create or update the target language JSON files (e.g., locales/sv.json, locales/de.json, locales/fr.json)