Skip to content

API reference

@intl-ai/api is the runtime-agnostic core of intl-ai. It exposes one function and one config type.

runFill(config, options?)

typescript
import { runFill } from "@intl-ai/api";
import type { IntlAiConfig, RunFillOptions, RunFillResult } from "@intl-ai/api";

const result: RunFillResult = await runFill(config, {
  locale: "es",
  force: false,
  dryRun: false,
});

The function walks your locale files, translates missing keys, updates the lockfile, and writes the new translations to disk.

Options

OptionTypeDescription
localestringTranslate only this locale.
forcebooleanRe-translate human-edited entries.
dryRunbooleanPreview changes without writing files.

Result

FieldTypeDescription
translatednumberNumber of keys translated.
skippednumberNumber of keys already up to date.
errorsnumberNumber of translation errors.
localesstring[]Locales that were processed.

IntlAiConfig

typescript
interface IntlAiConfig {
  defaultLocale: string;
  locales: string[];
  localeDir: string;
  model: unknown; // pass a Vercel AI SDK LanguageModel instance
  processor?: IntlAiProcessor;
  glossary?: Record<string, string>;
  maxRetries?: number;
}

For JSON config files, use IntlAiJsonConfigSchema and jsonConfigToIntlAiConfig from @intl-ai/api/internal.

JSON Schema

A JSON Schema for intl-ai.config.json is published at:

text
https://www.schemastore.org/intl-ai.json

Add it to your config for editor intellisense and CI validation:

json
{
  "$schema": "https://www.schemastore.org/intl-ai.json",
  "defaultLocale": "en",
  "locales": ["en", "es"],
  "localeDir": "./locales",
  "model": "your-provider/your-model",
  "apiKey": "${OPENAI_API_KEY}"
}