# Translate a pack

> Add French to a pack written in English, and find the texts you missed.

Your pack is in English and you want French players to read it in French.

## Solution

Every text of a pack is an object with one key per language. Add `fr` next to each `en`:

```json [quests.json]
{ "en": "Tidy the downloads", "fr": "Range les téléchargements" }
```

To find the texts you missed, save this script as `missing-fr.mjs` (it needs nothing but Node) and run it on each file:

```js [missing-fr.mjs]
// Lists every text of a content file that has English but no French, with where it is.
// Usage: node missing-fr.mjs my-pack/quests.json
import { readFileSync } from "node:fs";

const file = process.argv[2] ?? "my-pack/quests.json";
const missing = [];

(function walk(value, at) {
  if (Array.isArray(value)) return value.forEach((v, i) => walk(v, `${at}[${i}]`));
  if (!value || typeof value !== "object") return;
  if (typeof value.en === "string" && typeof value.fr !== "string") missing.push(`${at}: "${value.en}"`);
  for (const [k, v] of Object.entries(value)) walk(v, at ? `${at}.${k}` : k);
})(JSON.parse(readFileSync(file, "utf8")), "");

console.log(missing.length ? missing.join("\n") : `every text of ${file} has its French`);
process.exitCode = missing.length ? 1 : 0;
```

```sh [Terminal]
node missing-fr.mjs my-pack/quests.json
```

```text [Output, first lines]
quests[0].title: "My Pack: first steps"
quests[0].summary: "Replace this text: what the player learns here."
quests[0].steps[0].title: "Read what this pack is about"
quests[0].steps[1].title: "Pick a pace"
```

Each line is a text without French, and where it is. Once every text has its French, the script says so and exits with 0.

## How it works

The game speaks English and French. It shows each text in the player's language, and the English one when that language is missing, so a half-translated pack still works. `alta lint` does not report a missing translation; the script does, with the path of each text in the file. Address the player with "tu" in French, as the game does.

## Variants

- **In CI.** Add `node missing-fr.mjs <file>` after `alta lint` in your workflow: it fails the job when a text has no French. See [Check a repository in GitHub Actions](https://docs.altasystem.ai/recipes/ci-github-actions).
- **Other languages.** The game speaks English and French only for now; another key is kept in the file but never shown.
- **With an agent.** The [author MCP](https://docs.altasystem.ai/recipes/agent-writes-pack) reads and writes the same files: ask your agent to add the French and run the check.

**Next:**

- [Create a quest pack](https://docs.altasystem.ai/guides/quests/create-pack)
- [Check a repository in GitHub Actions](https://docs.altasystem.ai/recipes/ci-github-actions)
- [Let an agent write a pack](https://docs.altasystem.ai/recipes/agent-writes-pack)
