# General Translation Integrations: paraglide-context
URL: https://generaltranslation.com/en-US/docs/integrations/paraglide/reference/paraglide-context.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Write the source code around each Paraglide JS message usage to metadata files. API reference for the paraglide-context command.

The command is installed with `@generaltranslation/paraglide-js`. One run analyzes the app, writes the metadata files, and exits. Run it before [`gt translate`](/docs/cli/reference/commands/translate).

## Overview [#overview]

```bash
npx paraglide-context [root] [options]
```

`root` is the project, or a directory in it. It defaults to the working directory. Every path a flag takes is relative to the project root: the nearest `package.json` at or above `root`.

[`collectContext`](/docs/integrations/paraglide/reference/collect-context) does the same from code and takes the same options.

## How it works [#how-it-works]

- Selects the source files, resolves their imports, and finds every usage of a Paraglide JS message. (See [Usage detection](/docs/integrations/paraglide/reference/usage-detection)).
- Writes a metadata file next to each base-locale message file, such as `messages/en.metadata.json`. (See [Metadata files](/docs/integrations/paraglide/reference/metadata-files)).
- Never runs the app's bundler. Import aliases are read from `tsconfig.json`, `package.json`, and a Vite, webpack, or rspack config.
- Prints warnings for anything it skipped. Warnings do not change the exit code.

## Flags [#flags]

Each flag sets one option of [`collectContext`](/docs/integrations/paraglide/reference/collect-context#options), where its behavior is documented in full. Repeat a flag marked *repeatable* to pass several values.

| Parameter | Description | Type | Optional | Default |
| --- | --- | --- | --- | --- |
| `[root]` | The project, or a directory in it. Sets [`root`](/docs/integrations/paraglide/reference/collect-context#root). | `string` | Yes | Working directory |
| `--include <path>` | Path or glob to analyze. Repeatable. Sets [`include`](/docs/integrations/paraglide/reference/collect-context#include). | `string[]` | Yes | The whole project |
| `--exclude <path>` | Path or glob to skip. Repeatable. Sets [`exclude`](/docs/integrations/paraglide/reference/collect-context#exclude). | `string[]` | Yes | Tests and tool configs |
| `--outdir <dir>` | Paraglide JS output directory to use without verification. Repeatable. Sets [`outdirs`](/docs/integrations/paraglide/reference/collect-context#outdirs). | `string[]` | Yes | Detected |
| `--project <dir>` | inlang project whose messages get metadata files. Repeatable. Sets [`inlangProjects`](/docs/integrations/paraglide/reference/collect-context#inlang-projects). | `string[]` | Yes | Detected |
| `--alias <name=path>` | Import alias, such as `~=./src`. A replacement that starts with `.` resolves from the project root. Repeatable. Sets [`alias`](/docs/integrations/paraglide/reference/collect-context#alias). | `string[]` | Yes | — |
| `--no-bundler-config` | Do not read aliases from a bundler config. Sets [`bundlerConfigs`](/docs/integrations/paraglide/reference/collect-context#bundler-configs) to `[]`. | `boolean` | Yes | `false` |
| `--radius <lines>` | Lines of context above and below each usage. A non-negative integer. Sets [`radius`](/docs/integrations/paraglide/reference/collect-context#radius). | `number` | Yes | `10` |
| `--verbose` | Print a summary: the usages found, the files analyzed, the output directories used, and the config the aliases were read from. | `boolean` | Yes | `false` |
| `-h, --help` | Show the usage text. | `boolean` | Yes | `false` |

The `targets`, `languages`, `autoImports`, `conditions`, and `rootDirectory` options have no flag. Set them with [`collectContext`](/docs/integrations/paraglide/reference/collect-context).

## Example [#example]

```bash
# Analyze the app in the working directory
npx paraglide-context

# Analyze one app of a monorepo, with a summary
npx paraglide-context apps/web --verbose

# Analyze src and a shared package, with 5 lines of context
npx paraglide-context --include src --include ../shared --radius 5

# Declare an alias and skip the bundler config
npx paraglide-context --alias ~=./src --no-bundler-config
```

## Other notes [#notes]

| Exit code | Meaning |
| --- | --- |
| `0` | The run finished, with or without warnings. |
| `1` | An error stopped the run, such as a metadata file that could not be written. The error is printed. |
| `2` | Unknown flag, missing value, more than one `root`, or a `--radius` that is not a non-negative integer. The usage text is printed. |

- Warnings start with `[paraglide-context]` and go to standard error.
- A metadata file is written only when its content changes, so a second run with no source changes writes nothing.

## Sitemap

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