# AGENTS.md — foundryvtt-wh4-lang-fr-fr

FoundryVTT WFRP4e French translation module (wh4-fr-translation).

## Quick start

```bash
npm run build           # packs scripts/*.js → modules/loadScripts.js (do NOT edit loadScripts.js manually)
python3 -mjson.tool fr.json > /dev/null    # validate JSON (CI check)
python3 -mjson.tool module.json > /dev/null
```

No test framework exists. Only automated check is JSON validity (`.gitea/workflows/validate.yaml` on every push).

## Architecture

- **`fr.json`** (2715 keys) — UI/system flat key→val translations (`WFRP4E.*` namespace)
- **`compendium/*.json`** — compendium translations named `{source-module}.{pack-type}.json`; entries keyed by English `id`
- **`scripts/*.js`** — ActiveEffect scripts named by Foundry item IDs (GUID-like `a7v422EZcOUUC20X.js`)
- **`modules/loadScripts.js`** — **generated** by `npm run build`; never edit directly
- **`modules/babele-register.js`** — registers all compendium JSONs with Babele at `init` hook; contains all converter logic
- **`modules/addon-register.js`** — patches `game.wfrp4e.config.*` with French strings at `init`/`ready`
- **`modules/config-patch.js`** — `WH4FRPatchConfig` class (skill list translation, talent list, NPC details)
- **`modules/import-stat-2.js`** — French stat block parser (replaces WFRP4e default)
- **`wh4_fr.js`** — entry point, inits `travelv2` and `inn` submodules from `modules/`
- **`packs/`** — custom French compendium packs (LevelDB format)
- **`patch-styles.css`** — CSS patches

## Critical conventions

- **Never use French words as JS variable names** in `scripts/`. `Blessures` and `Tests` shadow WFRP4e internals (the system uses `game.wfrp4e.config.*` lookup based on English names, and `Blessures`/`Tests` as variable names break this). Scan with:
  ```bash
  node find-blessures-variables.cjs
  node find-tests-variables.cjs
  ```
- Conflicts in the release workflow: `compatibility-verified: '13'` in `.gitea/workflows/release.yaml` but `"verified": "14"` in `module.json`. The CI step overwrites the release yaml's value — but if adding module.json updates, match both.

## Upstream sync workflow

When updating to a new WFRP4e release:

```bash
node tools/copy-new-scripts.js --list       # count new scripts
node tools/copy-new-scripts.js --dry-run    # preview
node tools/copy-new-scripts.js --copy       # copy new scripts
node tools/sync-scripts.js                  # compare scripts with upstream
node tools/translate-scripts.js             # apply auto-translation passes
node tools/check-tests.js                   # scan for "Tests" in scripts/ content
```

## Release

Published via Gitea release. The zip includes: `module.json`, `fr.json`, `wh4_fr.js`, `patch-styles.css`, `README.md`, `LICENSE`, `compendium/`, `modules/`, `packs/`, `icons/`, `images/`, `trade/`.

Detailed architecture reference in `.github/copilot-instructions.md`.
