---
title: "Getting started"
description: "Run x18n check on a project, write a config with x18n init, and run the check in CI."
canonical_url: "https://x18n.dev/guide/getting-started"
---
# Getting started

> Run x18n check on a project, write a config with x18n init, and run the check in CI.

x18n needs Node.js 22 or later. Run the commands in this page in the root directory of your project.

## Let your agent install it

Copy this prompt to your coding agent. It sets x18n up for you:

```md
Set up https://x18n.dev/ in this project. Run `pnpx @x18n/cli prompt setup` and
follow the instructions it prints. Ask me about anything you cannot decide,
in one message.
```

`x18n prompt setup` prints the `x18n-setup` skill, so this works in any agent, with or without a skills system. See [The x18n skills](https://x18n.dev/agents/skill) for what the skill does. To set x18n up yourself, follow the steps below.

## Try it without a config

x18n works without a config file. It reads i18n-ally settings when the project has them, detects the i18n library from `package.json` (including the workspace packages of a monorepo), and looks for locale files in directories such as `locales`, `i18n`, `lang` or `messages`.

1. Show what x18n found:
   ```sh
   pnpx @x18n/cli
   ```

   The output lists the locales with their coverage, and the counts of resources, keys and usages.
2. Check the project:
   ```sh
   pnpx @x18n/cli check
   ```

`x18n check` prints each problem with its file, line and column:

```
src/App.vue:17:15
 ERROR  "app.titel" is not defined in en.  missing-key
16 │   <main>
17 │     <p>{{ $t('app.titel') }}</p>
   │               ~~~~~~~~~
18 │   </main>

src/locales/de.json:4:6
 ERROR  "app.greeting" in de has different placeholders than en: missing name.  placeholder-mismatch
3 │     "title": "Spielwiese",
4 │     "greeting": "Hallo",
  │      ~~~~~~~~
5 │     "footer": "Gemacht mit x18n"

src/locales/en.json:18:4
 WARNING  "unused" is not used.  unused-key
17 │   "app.save": "Save",
18 │   "unused": "Nobody uses me",
   │    ~~~~~~
19 │   "app.title": "Welcome back"

✖ 2 errors  ⚠ 1 warning  3 files
```

The command exits with code 1 when it finds errors. Warnings do not fail it. See [Checks](https://x18n.dev/checks) for every check.

If x18n finds the wrong files, or none, run `pnpx @x18n/cli doctor`. It shows the detected presets, the resources that each locale finder found, and the source files that each scanner read.

## Install

To run `x18n` from your project scripts, add `@x18n/cli` as a dev dependency:

::code-group
```sh [pnpm]
pnpm add -D @x18n/cli
```

```sh [npm]
npm install -D @x18n/cli
```

```sh [yarn]
yarn add -D @x18n/cli
```
::

## Write a config

`x18n init` detects the setup and writes `x18n.config.ts`:

```sh
pnpx @x18n/cli init
```

```ts [x18n.config.ts]
import { defineConfig } from '@x18n/core'

// Detected presets: vue-i18n. They apply automatically.
export default defineConfig({
  sourceLocale: 'en',
  resources: [
    {
      pattern: 'src/locales/{locale}.{ext}',
    },
  ],
})
```

A project that has no `package.json`, such as a PHP or Ruby project, can use YAML or JSON instead. These files need no installed package:

```sh
pnpx @x18n/cli init --format yml
```

`x18n init` refuses to replace an existing config. Pass `--force` to replace it. See [Configuration](https://x18n.dev/guide/configuration) for every way to change the setup.

## Run the check in CI

Add a script to `package.json`:

```json [package.json]
{
  "scripts": {
    "i18n:check": "x18n check"
  }
}
```

Then run `pnpm i18n:check` (or `npm run i18n:check`) in your CI. [CI](https://x18n.dev/surfaces/ci) shows a GitHub Actions workflow that puts the problems on the lines of a pull request.

## Next steps

- [Concepts](https://x18n.dev/guide/concepts): the names that x18n uses, such as resource, key and usage.
- [CLI and x18n check](https://x18n.dev/surfaces/cli): read, add, rename and delete keys from the terminal.
- [VS Code](https://x18n.dev/surfaces/vscode): see translations in place in the editor.
- [Agent workflows](https://x18n.dev/agents/workflows): let a coding agent translate and clean up messages.
- [Migration from i18n-ally](https://x18n.dev/migration): convert existing i18n-ally settings.


## Sitemap

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