JavaScript

Languine supports JavaScript/TypeScript localization files, perfect for modern web applications. This format handles both object literals and module exports, supporting nested structures and dynamic content.


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": {
    "js": {
      "include": ["src/locales/[locale].js"]
    }
  }
}

Translating

With your config set, run:

typescript
npx languine@latest translate

When you run this command, Languine will:

  • Load your source JavaScript files (e.g., src/locales/en.js)
  • Detect any new or modified translation strings
  • Generate translations for your target languages
  • Create or update the target language files (e.g., src/locales/sv.js)
  • Preserve module structure and exports
  • Handle nested objects and arrays
  • Maintain code formatting and comments
  • Generate TypeScript types if enabled