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.
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",
// },
});
| Field | Type | Description |
|---|
model | LanguageModel | Vercel AI SDK model instance |
sourceLocale | string | Source language code (e.g. "en") |
targetLocales | string[] | Target language codes |
messagesDir | string | Path to messages directory |
| Field | Type | Default | Description |
|---|
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
Required when mode is "inline".
| Field | Type | Description |
|---|
inline.componentPath | string | Import path for the <T> component (e.g. "@/components/t") |
| Field | Type | Default | Description |
|---|
batchSize | number | 50 | Keys per AI request |
concurrency | number | 3 | Parallel batch limit |
context | string | — | Project context for better translations |
glossary | Record<string, string> | — | Terms that should not be translated |
tone | string | — | Translation tone (e.g. "professional", "casual") |
retries | number | 2 | Retry attempts on failure |
| Field | Type | Default | Description |
|---|
include | string[] | — | Glob patterns for files to scan |
exclude | string[] | — | Glob patterns to exclude |
keyStrategy | "hash" | "path" | "hash" | Key generation strategy |
translatableProps | string[] | ["placeholder", "title", "alt", "aria-label"] | JSX props to extract |
i18nImport | string | "next-intl" | i18n library import source |
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.