---
title: "Translate and review prompts"
description: "x18n writes prompts that describe translation work for an agent or an LLM, then checks the results."
canonical_url: "https://x18n.dev/agents/prompts"
---
# Translate and review prompts

> x18n writes prompts that describe translation work for an agent or an LLM, then checks the results.

x18n does not call machine translation services. Instead, it writes a translate prompt: plain markdown that describes the work, built from the state of the project. You paste it into an LLM, or an agent follows it. Then x18n checks the results.

## Translate prompt

```sh
x18n prompt translate --to de
```

The prompt holds the messages that are missing or empty in `de`, 50 at a time. A shortened example:

~~~md
# Translate 2 messages from en to de (German)

## Rules

- Keep every placeholder exactly as written (`{name}`, `@:key`); do not translate their names.
- Keep markup tags and their attributes as they are.
- Match the tone and wording of the existing messages in the target locale.
- Do not translate glossary terms marked "do not translate".
- de uses the plural categories one, other.

## Existing de messages (style reference)

- `app.title`: "My App" → "Meine App"
- `nav.home`: "Home" → "Start"

## Messages

### `nav.about`

- Source: "About"
- Used in `src/App.vue:14`:

  ```
        <a>{{ t('nav.home') }}</a>
        <a v-t="'nav.about'" />
      </nav>
  ```

### `pages.about.title`

- Source: "About us"
- Used in `src/App.vue:16`:

  ```
      </nav>
      <p>{{ $t(`pages.${page}.title`) }}</p>
      <p>{{ $t('app.titel') }}</p>
  ```

## How to write results

- Write a JSON file `{ "de": { "<key>": "<translation>" } }` and run `x18n apply <file> --json`, or run `x18n set <key> --locale de --value <text>` per key.
- Then run `x18n check --only placeholder-mismatch,invalid-syntax --locale de --json` and fix the reported keys.
~~~

The parts of the prompt are:

- Rules: the placeholder syntaxes of the project, markup, tone, and the glossary. Presets add notes for their library, for example the plural suffixes of i18next.
- Glossary: the entries of the `glossary` config, with their translation in the target locale.
- Style reference: up to five existing messages of the target locale, as examples of its tone. A value that is a copy of the source is never an example.
- Messages: the key, the source value, its placeholders, its description, its values in related locales, and the code around up to two usages. The code and the description help with short words such as "Open" or "Save", whose meaning depends on where they appear.
- How to write results: the commands that write and check the translations.

When more messages remain, the prompt says how many, and gives the command for the next batch with `--cursor`.

## Options

| Option                | Effect                                                                                                                                      |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `--to <locale>`       | The target locale. Required for `translate`.                                                                                                |
| `--keys <glob>`       | Only keys that match the glob, for example `"pages.**"`.                                                                                    |
| `--namespace <ns>`    | Only keys of one namespace.                                                                                                                 |
| `--limit <n>`         | Messages per prompt. The default is 50.                                                                                                     |
| `--cursor <cursor>`   | Continue from `nextCursor` of the previous prompt.                                                                                          |
| `--format json`       | Print the parts as data, for tools that build their own prompt. `--json` does the same.                                                     |
| `--no-context`        | Leave out the code around usages.                                                                                                           |
| `--related [locales]` | Show the values of these locales (comma separated) next to each message, in place of the [related locales](#related-locales) of the target. |
| `--no-related`        | Leave out the values of related locales.                                                                                                    |
| `--stale`             | Also translate stale translations: those older than their source message. Needs git history.                                                |
| `--check [ids]`       | Also translate values that checks report in the target locale. Without ids, every check; with ids (comma separated), only those checks.     |

## Descriptions

Many formats can say what a message means, for the translator. The prompt shows that description under the source value:

```md
### `appName`

- Source: "Notes"
- Description: "Name of the extension in the store"
```

The description comes from the source locale's resource, else from the resource of another locale, else from the code. The built-in formats and presets read:

| Where                  | Description                                                                                               |
| ---------------------- | --------------------------------------------------------------------------------------------------------- |
| ARB                    | `description` of the `@key` entry                                                                         |
| Chrome `messages.json` | `description` next to `message`                                                                           |
| gettext `.po`          | extracted (`#.`) and translator (`# `) comments                                                           |
| XLIFF 1.2 and 2.0      | `<note>`s of the unit, except location notes. A `meaning` note reads as `Meaning: ...`.                   |
| XMB                    | the `desc` and `meaning` attributes                                                                       |
| `.resx`                | the `<comment>` of the `<data>` element                                                                   |
| react-intl code        | `description` next to `id` in `formatMessage`, `defineMessage`, `defineMessages` and `<FormattedMessage>` |

A [format](https://x18n.dev/plugins/capabilities#formats) returns descriptions from `parse`, a [resource transform](https://x18n.dev/plugins/capabilities#resource-transforms) from `describe`, and a call spec names the property that holds one with `description`. A rule asks the agent to follow the description and not to translate it.

## Related locales

The value of a message in a related locale is a good start for a translation: `pt` when translating to `pt-BR`, `pt-BR` when translating to `pt`. The prompt shows up to two of them under the source value:

```md
### `bus`

- Source: "Bus"
- In pt: "Autocarro"
- In pt-PT: "Autocarro"
```

The related locales of a target are, nearest first:

1. the locales of its [fallback chain](https://x18n.dev/references/config#localefallbacks), such as `pt` for `pt-BR` with `localeFallbacks: { 'pt-BR': 'pt' }`,
2. the other locales of the same language: those that share more subtags with the target first (`zh-Hant` and `zh-Hant-HK` before `zh-Hans` for `zh-Hant-TW`), then the shorter codes, then in alphabetical order.

The source locale is never a related locale: the prompt shows it anyway. A value that is a copy of the source is left out. `--related es,fr` names the related locales instead, which also works across languages, and `--no-related` leaves them out. A rule asks the agent to keep what fits the target, and to change the spelling, words and forms that differ.

## Size

Each prompt holds at most 50 messages (`--limit`), the code around at most two usages per message, at most five style examples and at most two related values per message. A description or a related value longer than 300 characters is cut.

## Translate reported values

The translate prompt holds only messages without a value. A value can still be wrong: a copy of the source text, pasted in to fill a gap or taken from the wrong side of a merge, or a value older than its source message. `--stale` and `--check` add such messages:

```sh
x18n prompt translate --to de --stale
x18n prompt translate --to de --check identical-to-source
```

`--stale` adds the translations that the [`stale-translation`](https://x18n.dev/checks/stale-translation) check reports. Each item shows the source text from when the translation last changed. `--check` adds the values that checks report in the target locale, such as [`identical-to-source`](https://x18n.dev/checks/identical-to-source), [`glossary`](https://x18n.dev/checks/glossary) and [`placeholder-mismatch`](https://x18n.dev/checks/placeholder-mismatch). A check must be on to report: `--check` runs the checks of the config. Each item shows the current value and what was reported:

```md
### `greeting`

- Source: "Hello"
- Current de: "Hello"
- Reported: "greeting" in de is the same as in en. (`identical-to-source`)
```

A rule asks the agent to leave out a value that is right as it is, such as a word that is the same in both languages. To stop a key from being reported, add it to `ignoreKeys`, or add the term to the `glossary` with `doNotTranslate: true`.

## Review prompt

```sh
x18n prompt review --locale de
```

The review prompt holds the messages that `de` already has. It asks the agent to check the meaning, the placeholders, the glossary terms, the tone and the length of each one, and to leave a suggestion or a change request for each wrong one with `x18n review` (with `review.enabled: false`, to fix it with `x18n set`). Each item shows the source value, its placeholders, its description, its values in related locales and the current translation. The prompt accepts the same options as the translate prompt, with `--locale` in place of `--to`.

## Check the results

Prompts ask for results in the shape that `x18n apply` reads:

```json [translations.json]
{
  "de": {
    "pages.about.title": "Über uns"
  }
}
```

```sh
x18n apply translations.json
x18n check --only placeholder-mismatch,invalid-syntax --locale de
```

`x18n apply` writes nothing if a value drops or adds a placeholder. It lists the problems and exits with code 1. The check then finds syntax errors, such as an ICU plural without an `other` case.

## Setup and check prompts

Two more prompts print the shipped [skills](https://x18n.dev/agents/skill), for agents that have no skills system:

```sh
x18n prompt setup   # set x18n up, or migrate from i18n-ally
x18n prompt check   # run x18n check and fix what it reports
```

They take no options.

## Where prompts appear

The same builder makes the prompt on every surface:

- the CLI: `x18n prompt translate` and `x18n prompt review`,
- the MCP tool [`x18n_translate_prompt`](https://x18n.dev/references/mcp-tools#x18n_translate_prompt),
- the "Copy translate prompt" button on the locale and key pages of the [UI](https://x18n.dev/surfaces/ui),
- the "Copy Translate Prompt" and "Translate with Agent" commands and the hover links in [VS Code](https://x18n.dev/surfaces/vscode),
- the `x18n/translatePrompt` request of the [language server](https://x18n.dev/references/lsp-protocol).

A plugin can add rules and notes with the `translatePrompt` hook. See [Capabilities](https://x18n.dev/plugins/capabilities#translate-prompts).


## Sitemap

See the full [sitemap](https://x18n.dev/sitemap.md) for all pages.
