Saltar al contenido principal

Configuration

Rosetta works zero-config — it auto-detects locale files, format, and target languages from your project. For more control, create i18n-rosetta.config.json in your project root, or run:

npx i18n-rosetta init

Full Config Reference

i18n-rosetta.config.json
{
"version": 3,
"inputLocale": "en",
"localesDir": "./locales",
"contentDir": null,
"translatableFields": null,
"format": "auto",
"model": "openai/gpt-4o-mini",
"defaultMethod": "llm",
"batchSize": 30,
"fallbackPrefix": "[EN] ",
"apiKeyEnvVar": "OPENROUTER_API_KEY",
"baseUrl": "",
"pairs": {},
"languages": {},
"lint": {
"srcDir": null,
"ignore": ["node_modules", ".next", "dist"],
"minLength": 2
},
"seo": {
"urlPattern": "/:locale/:path",
"pages": null
},
"typegen": {
"output": null,
"autoGenerate": false
}
}

Fields

FieldTypeDefaultDescription
versionnumber3Config schema version. Always 3.
inputLocalestring"en"Source language code (BCP 47).
localesDirstring"./locales"Path to locale files. Rosetta scans this directory.
contentDirstringnullHugo content directory. Enables Markdown body translation.
translatableFieldsstring[]nullOverride default translatable frontmatter fields for content translation. null uses built-in defaults (title, description, summary).
formatstring"auto"File format: json, toml, yaml, or auto (detect from extension).
modelstring"openai/gpt-4o-mini"Default OpenRouter model for LLM methods.
defaultMethodstring"llm"Default translation method: llm, llm-coached, google-translate, api. Overridden by --method CLI flag.
batchSizenumber30Keys per translation batch. Higher = fewer API calls, but larger prompts.
fallbackPrefixstring"[EN] "Prefix added to untranslated fallback values. Used by audit to detect incomplete translations.
apiKeyEnvVarstring"OPENROUTER_API_KEY"Environment variable name for the API key. Override for custom env var names.
baseUrlstring""Base URL for SEO artifact generation (hreflang, sitemaps, JSON-LD).
pairsobject{}Per-pair method, model, and quality overrides. See Pair Configuration.
languagesobject{}Per-language overrides. See Language Configuration.
lint.srcDirstringnullSource directory for lint scanning. null = auto-detect from framework.
lint.ignorestring[]["node_modules", ...]Glob patterns to exclude from lint.
lint.minLengthnumber2Minimum string length to flag as hardcoded.
seo.urlPatternstring"/:locale/:path"URL pattern template for hreflang tag generation.
seo.pagesstring[]nullExplicit page list for SEO. null = auto-detect from locale keys.
typegen.outputstringnullOutput path for generated TypeScript types. null = disabled.
typegen.autoGeneratebooleanfalseAuto-regenerate types after each sync.

Pair Configuration

Each source→target pair can be independently configured:

{
"pairs": {
"en:fr": {
"method": "google-translate",
"qualityTier": "high"
},
"en:ja": {
"method": "llm",
"model": "google/gemini-2.5-pro"
},
"en:crk": {
"methodPlugin": "crk-coached-v1"
}
}
}

Pair Fields

FieldTypeDescription
methodstringTranslation method: llm, llm-coached, google-translate, api
methodPluginstringName of an installed plugin (from .rosetta/methods/)
modelstringOverride the default model for this pair
endpointstringRemote API endpoint URL. Required when method is api.
qualityTierstringDisplay tier: standard, high, research, verified

Language Configuration

Languages can be configured with a register string (shorthand) or a full object:

{
"languages": {
"fr": "Formal academic French. Use vous-form.",
"crk": {
"name": "Plains Cree",
"register": "SRO syllabics with grammatical precision.",
"model": "google/gemini-2.5-pro",
"batchSize": 5,
"maxRetries": 5,
"script": "cans"
}
}
}

Language Fields

FieldTypeDescription
registerstringStyle/tone instructions injected into every LLM prompt for this locale
namestringHuman-readable language name (for status display)
modelstringOverride the default model
batchSizenumberOverride the default batch size
maxRetriesnumberMaximum retry budget for failed batches (default: 3)
scriptstringISO 15924 script code. Triggers script validation in the quality gate.

:::info Inheritance chain Settings resolve in this order (first wins):

pair-levellanguage-levelglobal configdefaults

For example, if pairs["en:fr"] sets model, it overrides both the language-level and global model values. :::

Non-English Source

If your source language isn't English:

# CLI flag (one-time)
npx i18n-rosetta sync --source fr
i18n-rosetta.config.json (permanent)
{
"inputLocale": "fr"
}

Lock File

Rosetta creates .i18n-rosetta.lock to track SHA-256 hashes of translated source values. Commit this file so all developers share the same translation baseline.

When a source value changes, the hash no longer matches, and rosetta re-translates that key on the next sync.

.rosettaignore

Create .rosettaignore in your project root to exclude files from lint scanning. Uses glob patterns, like .gitignore:

.rosettaignore
src/components/legacy/**
src/utils/constants.js
**/*.test.js