Reference

Programmatic API

Every operation behind a command is exported from @the-i18n-kit/cli. A tool that needs translation data can call the operation rather than spawning the CLI and parsing its output — which is how the MCP server is built.

Using It

scripts/coverage.ts
import { detectConfig, getTranslationStatus } from '@the-i18n-kit/cli'

const config = await detectConfig(process.cwd())
const status = await getTranslationStatus({ projectDir: process.cwd() })

console.log(`${config.locales.length} locales across ${config.layers.length} layers`)

Operations take a projectDir and return plain data. Nothing writes to stdout, so the return value is the whole result — there is no output to parse and no stdout guard to work around.

What Is Exported

The same set the MCP server consumes, grouped by what it does:

GroupOperations
DetectiondetectConfig, listLocaleDirs, listNamespaces
ReadinggetTranslations, getMissingTranslations, getTranslationStatus, findEmptyTranslations, searchTranslations
WritingwriteTranslations, addTranslations, updateTranslations, removeTranslations, renameTranslationKey
TranslatingtranslateMissing, translateKey
AnalysisfindOrphanKeys, removeOrphanKeys, scanCodeUsage, findDuplicateKeys, checkUndefinedKeys
SetupscaffoldLocaleFiles
LocalesfindLocaleImpl, resolveProtectedLocales

Result types are exported alongside them, so a consumer types its own handling rather than restating the shape.

The command for each of these is documented in the CLI reference, including its flags. An operation and its command take the same options under the same names, because the command is a thin wrapper around the operation.

Limits

  • The public surface is what @the-i18n-kit/cli exports, and nothing deeper. The build emits content-hashed chunks, so a path into dist is not a stable import and will change on the next release.
  • Operations validate their own input and throw a ToolError carrying a code. They do not set an exit code — that is the command's job, not the operation's.
  • Translating needs a provider. Called without one, translateMissing returns every key as skipped with reason no-provider rather than throwing; see the translate command.
Copyright © 2026