translate-kit

Configuration

Full configuration reference for translate-kit.

translate-kit is configured via a translate-kit.config.ts file at your project root. The config is loaded using c12 and validated with Zod.

Full Example

import { defineConfig } from "translate-kit";
import { openai } from "@ai-sdk/openai";

export default defineConfig({
  // Required
  model: openai("gpt-4o-mini"),
  sourceLocale: "en",
  targetLocales: ["es", "fr", "de", "pt", "ja"],
  messagesDir: "./messages",

  // Mode: "keys" (default) or "inline"
  mode: "keys",

  // Translation options
  translation: {
    batchSize: 50,
    concurrency: 3,
    context: "SaaS application for project management",
    glossary: {
      "Acme": "Acme",
      "Dashboard": "Dashboard",
    },
    tone: "professional",
    retries: 2,
  },

  // Scanner options (for scan + codegen commands)
  scan: {
    include: ["src/**/*.tsx", "app/**/*.tsx"],
    exclude: ["**/*.test.*"],
    keyStrategy: "hash",
    translatableProps: ["placeholder", "title", "alt", "aria-label"],
    i18nImport: "next-intl",
  },

  // Inline mode options (required when mode is "inline")
  // inline: {
  //   componentPath: "@/components/t",
  // },
});

Required Fields

FieldTypeDescription
modelLanguageModelVercel AI SDK model instance
sourceLocalestringSource language code (e.g. "en")
targetLocalesstring[]Target language codes
messagesDirstringPath to messages directory

Mode

FieldTypeDefaultDescription
mode"keys" | "inline""keys"Translation mode. See Inline Mode
  • keys — replaces strings with t("key") calls and generates a source locale JSON file
  • inline — wraps strings with <T id="key">text</T> components, source text stays in code

Inline Options

Required when mode is "inline".

FieldTypeDescription
inline.componentPathstringImport path for the <T> component (e.g. "@/components/t")

Translation Options

FieldTypeDefaultDescription
batchSizenumber50Keys per AI request
concurrencynumber3Parallel batch limit
contextstringProject context for better translations
glossaryRecord<string, string>Terms that should not be translated
tonestringTranslation tone (e.g. "professional", "casual")
retriesnumber2Retry attempts on failure

Scanner Options

FieldTypeDefaultDescription
includestring[]Glob patterns for files to scan
excludestring[]Glob patterns to exclude
keyStrategy"hash" | "path""hash"Key generation strategy
translatablePropsstring[]["placeholder", "title", "alt", "aria-label"]JSX props to extract
i18nImportstring"next-intl"i18n library import source

Key Strategies

  • hash — generates stable 12-character SHA-256 hashes. Good for large codebases where readability is less important.
  • path — generates human-readable keys like ComponentName.parentTag.slug. More readable but may change if components are renamed.

AI semantic key generation is used automatically during scan to produce namespace-style keys like common.save, nav.dashboard, form.enterName.