Quick start
Configure Langnostic for message catalogs and Markdown, then run your first translation.
Prerequisites
- A supported Node.js version:
^22.18.0,^24.11.0, or>=26.0.0. - Source files in a supported format.
- An AI provider account and API key. Provider usage charges are separate from Langnostic licensing.
Install the CLI and plugin
For the default OpenAI and FormatJS setup, install both dependencies:
npm install langnostic @langnostic/plugin-formatjs -Dpnpm add langnostic @langnostic/plugin-formatjs -Dyarn add langnostic @langnostic/plugin-formatjs -Dbun add langnostic @langnostic/plugin-formatjs -Dnub add langnostic @langnostic/plugin-formatjs -Daube add langnostic @langnostic/plugin-formatjs -DIgnore debug output, but keep translation files and MDX registries in version control:
.langnostic/
Initialize configuration
npx langnostic initpnpm dlx langnostic inityarn dlx langnostic initbunx langnostic initnubx langnostic initaube dlx langnostic initFor a plain JSON configuration, use npx langnostic init --format json and follow
the JSON configuration example.
If no project configuration already exists, this creates the following
langnostic.config.ts in your current directory:
import FormatJSPlugin from '@langnostic/plugin-formatjs';
import type { ConfigType } from 'langnostic';
export default {
ai: {
provider: 'openai',
model: 'gpt-6.1-sol',
},
groups: [
{
name: 'app-strings',
paths: [
{
source: './src/locales/en-US.json',
target: './src/locales/{locale}.json',
},
],
plugin: FormatJSPlugin(),
},
],
localeConfig: {
source: 'en-US',
target: ['zh-CN'],
},
} satisfies ConfigType;
Change the paths to match your project and add target locales as needed.
{locale} is replaced with each target locale. For example, adding pt-BR
would also generate src/locales/pt-BR.json.
Create the source catalog before translating. A minimal FormatJS catalog is:
{
"welcome": {
"defaultMessage": "Welcome, {username}!",
"description": "Greeting for a signed-in user"
}
}
The plugin also accepts flat string values. It does not interpret arbitrary nested JSON structures.
Configure your AI provider
Add your key to a .env file in the directory where you run the command:
OPENAI_API_KEY="your-api-key-here"
The CLI loads this file automatically. Keep credentials out of version control.
The examples use the OpenAI provider. Langnostic includes adapters for OpenAI,
Anthropic, Google, and OpenAI-compatible endpoints. Set ai.provider and
ai.model as plain strings; no provider package installation is needed. The
model must support structured translation output.
See AI settings for credentials, custom endpoints, native request parameters, and local servers. Changing the model does not automatically regenerate existing translations.
Translate and review
npx langnostic translatepnpm dlx langnostic translateyarn dlx langnostic translatebunx langnostic translatenubx langnostic translateaube dlx langnostic translateWith the generated configuration, this fills missing message IDs in
src/locales/zh-CN.json and removes IDs no longer present in the source:
src/
└── locales/
├── en-US.json
└── zh-CN.json
For a repeatable command, add a script to your existing package.json:
{
"scripts": {
"translate": "langnostic translate"
}
}
Then run npm run translate. See Workflows for review and CI
integration.
Translate Markdown/MDX
Install the MDX plugin alongside the CLI:
npm install @langnostic/plugin-mdx -Dpnpm add @langnostic/plugin-mdx -Dyarn add @langnostic/plugin-mdx -Dbun add @langnostic/plugin-mdx -Dnub add @langnostic/plugin-mdx -Daube add @langnostic/plugin-mdx -DFor this example, start with docs/en-US/getting-started.mdx. Replace your
configuration with this complete Markdown-only setup:
import MdxPlugin from '@langnostic/plugin-mdx';
import type { ConfigType } from 'langnostic';
export default {
ai: {
provider: 'openai',
model: 'gpt-6.1-sol',
},
localeConfig: {
source: 'en-US',
target: ['zh-CN', 'pt-BR'],
},
groups: [
{
name: 'docs',
plugin: MdxPlugin({ frontmatterExcludedKeys: ['slug'] }),
paths: [
{
source: './docs/en-US/**/*.mdx',
target: './docs/{locale}/**/*.mdx',
},
],
},
],
} satisfies ConfigType;
To translate catalogs and documents together, keep both groups in the
groups array, using a separate plugin instance for each group.
Given this source document:
---
title: Getting started
description: Learn how to get started
slug: getting-started
---
# Getting started
Welcome to our documentation!
<Alert>This is an important note.</Alert>
Run langnostic translate to generate both target documents and a registry:
docs/
├── en-US/
│ ├── getting-started.langnostic.json
│ └── getting-started.mdx
├── pt-BR/
│ └── getting-started.mdx
└── zh-CN/
└── getting-started.mdx
The plugin sends translatable frontmatter and document blocks to the model.
frontmatterExcludedKeys keeps fields such as slug out of translation
requests. Review the generated frontmatter, Markdown, JSX, and code examples;
syntax preservation is model-dependent.
Commit each source document’s *.langnostic.json registry with the source and
target files. The registry tracks source hashes and the blocks associated with
each target. It is separate from the ignored .langnostic/ debug directory.
Missing registries or changes to a target document’s block count can cause all source blocks to be translated again. See MDX change detection before restructuring translated documents.
Preview pending work
npx langnostic translate --dry-runpnpm dlx langnostic translate --dry-runyarn dlx langnostic translate --dry-runbunx langnostic translate --dry-runnubx langnostic translate --dry-runaube dlx langnostic translate --dry-runThe preview shows pending groups, source file paths, and string counts. It does not print individual strings or translated output, make AI requests, or apply file changes. Removal-only or reordering-only maintenance is not listed as pending translation work.
Inspect AI requests
npx langnostic translate --debugpnpm dlx langnostic translate --debugyarn dlx langnostic translate --debugbunx langnostic translate --debugnubx langnostic translate --debugaube dlx langnostic translate --debugDebug runs make real translation requests and write prompts, responses, and errors
under .langnostic/runs/. See CLI for flags and exit statuses, and
Configuration for all settings.