Marketing pages
Energetic, persuasive tone. Short punchy copy. Brand-aware terminology.
Context profiles let you assign different translation tones, terminology, and instructions to different parts of your application. Instead of treating all strings identically, koto adapts translations to match the intent of each section.
Consider the word “Submit” in two places:
Without context, a translation tool picks one and applies it everywhere. With context profiles, each usage gets the right translation.
Marketing pages
Energetic, persuasive tone. Short punchy copy. Brand-aware terminology.
Legal & compliance
Formal, precise language. Jurisdiction-appropriate legal terms. No ambiguity.
UI strings
Concise labels. Consistent with platform conventions (“Settings” not “Configuration”).
Support content
Friendly, helpful tone. Clear step-by-step instructions. Empathetic language.
Profiles live in the contexts section of your koto.config.ts. Each profile specifies which files it applies to, the desired tone, and any additional instructions.
import { defineConfig } from 'koto'
export default defineConfig({ sourceLocale: 'en', targetLocales: ['es', 'fr', 'de', 'ja'], files: ['src/locales/[locale].json'], provider: { name: 'openai', model: 'gpt-4o-mini', },
contexts: { // Applied to files not matched by any other context default: { tone: 'concise', instructions: 'UI strings. Keep translations short and consistent with platform conventions.', },
marketing: { tone: 'persuasive and energetic', instructions: 'Keep translations punchy. Prefer short, impactful words.', files: ['src/locales/marketing/[locale].json'], },
legal: { tone: 'formal and precise', instructions: 'Use jurisdiction-appropriate legal terminology. Avoid ambiguity.', glossary: './glossaries/legal.json', files: ['src/locales/legal/[locale].json'], },
support: { tone: 'friendly and helpful', instructions: 'Use clear, simple language. Be empathetic. Avoid jargon.', files: ['src/locales/support/[locale].json'], }, },})File matching — When koto translates a file, it checks which profile’s files pattern matches the file path.
Default fallback — If no profile matches, the default context is applied. If no default is defined, koto translates without additional context.
Prompt assembly — koto builds an LLM prompt that includes the profile’s tone, instructions, and any glossary terms.
Translation — The LLM translates with full awareness of the intended context, producing output that matches the desired tone and terminology.
toneType: string
A natural language description of the desired tone, included in the LLM prompt.
tone: 'concise'tone: 'formal and precise'tone: 'persuasive and energetic'tone: 'friendly, casual, and approachable'instructionsType: string
Additional guidance for the LLM — domain-specific rules, formatting constraints, or style notes.
instructions: 'UI strings. Keep translations under 30 characters where possible.'instructions: 'Legal copy. Use formal register. Preserve all placeholder variables.'filesType: string | string[]
Glob pattern(s) that determine which files this profile applies to. Uses the same [locale] placeholder as the top-level files option.
files: ['src/locales/marketing/[locale].json']files: ['src/locales/legal/[locale].json', 'src/locales/compliance/[locale].json']glossaryType: string
Path to a JSON glossary file. Terms are included in the LLM prompt to ensure consistent translation of domain-specific terminology.
glossary: './glossaries/legal.json'A glossary maps source terms to expected translations per locale:
{ "terms": { "Data Controller": { "es": "Responsable del tratamiento", "fr": "Responsable du traitement", "de": "Verantwortlicher", "ja": "データ管理者" }, "Consent": { "es": "Consentimiento", "fr": "Consentement", "de": "Einwilligung", "ja": "同意" } }}When a glossary is attached to a profile, koto sends the relevant terms to the LLM as reference.
Translate only the files belonging to one profile:
# Legal content onlynpx koto translate --context legal
# Marketing content onlynpx koto translate --context marketingUseful when you’ve updated only one section and want a fast, targeted run.
Start with default — Define a default context for general UI strings. It catches everything not matched by a specific profile.
Be specific with tone — Instead of “formal,” write “formal and precise, suitable for legal documents.” The more specific, the better the LLM performs.
Use glossaries for domain terms — Industry-specific terminology (legal, medical, financial) benefits from glossary files that enforce consistency.
Organize files by context — Structure locale files so each profile maps to a clear directory:
src/locales/├── en.json # default context├── marketing/│ └── en.json # marketing context├── legal/│ └── en.json # legal context└── support/ └── en.json # support contextKeep profiles focused — Each should represent a distinct translation need. If two have the same tone and instructions, merge them.