🎉 v1.0

Get started

  • Welcome
  • Documentation
  • Pricing
    Soon

Tools

  • I18n MCP
  • CLI
  • CI/CD Integrations
  • Compiler
    Alpha
  • Connect Your Engine

Resources

  • Languages
  • LLM Models
  • Guides

Company

  • Enterprise
  • CareersHiring!
Dashboard

Lingo.dev Compiler

  • How it works
  • Setup

Framework Integration

  • Next.js
  • Vite + React

Configuration

  • Configuration Reference
  • Translation Providers
  • Build Modes

Features

  • Manual Overrides
  • Custom Locale Resolvers
  • Automatic Pluralization
  • Locale Switching

Development

  • Development Tools
  • Project Structure

Guides

  • Best Practices
  • Migration Guide
  • Troubleshooting

Configuration Reference

Max PrilutskiyMax Prilutskiy·Updated 5 days ago·4 min read

Alpha

The Lingo.dev Compiler is in alpha. It is unstable, not recommended for production use, and APIs may change between releases.

The Lingo.dev Compiler configuration object controls how your React application is translated at build time. This page documents every available option with types, defaults, and usage examples.

Core options#

OptionTypeDefaultDescription
sourceRootstring"src"Directory containing translatable components. Relative to project root.
lingoDirstring".lingo"Directory for translation metadata and cache files.
sourceLocalestringrequiredLanguage code of your source content (e.g., "en").
targetLocalesstring[]requiredArray of target language codes (e.g., ["es", "de", "fr"]).
useDirectivebooleanfalseWhen true, only files with 'use i18n' directive are translated. When false, all files in sourceRoot are translated.
modelsstring | object"lingo.dev"Translation provider configuration. A string sets the default for all locale pairs. An object maps locale pairs to specific providers.
promptstringundefinedCustom system prompt for the translation LLM. Supports {SOURCE_LOCALE} and {TARGET_LOCALE} placeholders.
buildMode"translate" | "cache-only""translate"Controls whether the compiler generates new translations or uses only cached translations.

Dev options#

Options under the dev key control development-time behavior:

OptionTypeDefaultDescription
dev.usePseudotranslatorbooleanfalseGenerate instant fake translations (e.g., [!!! Welcome !!!]) instead of calling an LLM. No API key needed.
dev.translationServerStartPortnumber60000Starting port for the local translation server. The compiler auto-finds an available port in the range 60000-60099.
dev.translationServerUrlstringundefinedOverride the translation server URL. Useful for custom setups or remote translation servers.

Locale persistence#

Options under localePersistence control how the user's selected locale is stored and retrieved:

OptionTypeDefaultDescription
localePersistence.typestring"cookie"Persistence mechanism. Currently supports "cookie".
localePersistence.config.namestring"locale"Cookie name used to store the locale.
localePersistence.config.maxAgenumber31536000Cookie max-age in seconds (default is 1 year).

For custom persistence logic (localStorage, URL-based, headers), see Custom Locale Resolvers.

Pluralization#

Options under pluralization control automatic plural form detection and generation:

OptionTypeDefaultDescription
pluralization.enabledbooleantrueEnable or disable automatic pluralization detection.
pluralization.modelstring"groq:llama-3.1-8b-instant"LLM model used for detecting plural forms in source text. A smaller, faster model is recommended since detection is a simpler task than translation.

See Automatic Pluralization for details on how plural detection works.

Environment variables#

Environment variables override or supplement configuration:

VariableWhen requiredDescription
LINGO_BUILD_MODEOptionalOverrides the buildMode config option. Set to "translate" or "cache-only".
LINGODOTDEV_API_KEYWhen using "lingo.dev" modelsAPI key for the Lingo.dev localization engine. Obtain via npx lingo.dev@latest login.
OPENAI_API_KEYWhen using "openai:*" modelsOpenAI API key.
ANTHROPIC_API_KEYWhen using "anthropic:*" modelsAnthropic API key.
GOOGLE_API_KEYWhen using "google:*" modelsGoogle AI API key.
GROQ_API_KEYWhen using "groq:*" modelsGroq API key.
MISTRAL_API_KEYWhen using "mistral:*" modelsMistral API key.
OPENROUTER_API_KEYWhen using "openrouter:*" modelsOpenRouter API key.

Complete example#

ts
// next.config.ts
import type { NextConfig } from "next";
import { withLingo } from "@lingo.dev/compiler/next";

const nextConfig: NextConfig = {};

export default async function (): Promise<NextConfig> {
  return await withLingo(nextConfig, {
    sourceRoot: "./app",
    lingoDir: ".lingo",
    sourceLocale: "en",
    targetLocales: ["es", "de", "fr", "ja"],
    useDirective: false,
    models: {
      "*:*": "lingo.dev",
      "*:ja": "anthropic:claude-3-5-sonnet",
    },
    prompt: "Translate UI text from {SOURCE_LOCALE} to {TARGET_LOCALE}. Keep it concise.",
    buildMode: "translate",
    dev: {
      usePseudotranslator: true,
      translationServerStartPort: 60000,
    },
    localePersistence: {
      type: "cookie",
      config: {
        name: "locale",
        maxAge: 31536000,
      },
    },
    pluralization: {
      enabled: true,
      model: "groq:llama-3.1-8b-instant",
    },
  });
}

Next Steps#

Translation Providers
All supported LLM providers and locale-pair mapping
Build Modes
Dev, CI, and production workflows
Custom Locale Resolvers
Implement custom locale detection
Best Practices
Recommended patterns for production

Was this page helpful?