Files
midgard6-vtt/docs/localization.md
T
unknown 9568be0211 Turn boilerplate into a maintained, documented template
Rename newsystem -> fvtt-ts-react-boilerplate, install fvtt-types for
real typing throughout (DataModelConfig augmentation, typed sheet
overrides), wire up i18n (lang/en.json was an empty directory and
fr.json was empty), add MIT license, eslint/prettier/vitest tooling,
GitHub Actions CI, and extensive docs/ covering the architecture,
adding content, styling, localization, testing, and how to rename
this again for a new system.
2026-06-22 23:21:53 +02:00

1.6 KiB

Localization

system.json registers two languages:

"languages": [
  { "lang": "en", "name": "English", "path": "lang/en.json", "flags": {} },
  { "lang": "fr", "name": "Français", "path": "lang/fr.json", "flags": {} }
]

All keys live under a single BOILERPLATE root namespace to avoid colliding with Foundry core or other systems/modules:

{
  "BOILERPLATE": {
    "Attributes": { "strength": "Strength", "agility": "Agility", "spirit": "Spirit" },
    "Sheet": { "Biography": "Biography", "SendToChat": "Send to chat", "...": "..." },
    "Item": { "Quantity": "Quantity", "Description": "Description" }
  }
}

In React components, use the localize() helper from src/i18n.ts rather than calling game.i18n.localize() directly:

export const localize = (key: string) => game.i18n!.localize(key);
import { localize } from "../../i18n";

<label>{localize("BOILERPLATE.Sheet.Biography")}</label>;

Why the helper instead of inline game.i18n.localize(): fvtt-types types game (and game.i18n) as possibly undefined, since game genuinely isn't populated until Foundry's "ready" hook fires. Sheets only ever render after that point, so a single non-null assertion in one shared helper is safe and keeps every call site from repeating game.i18n!.localize(...).

When adding a new string: add the key to both lang/en.json and lang/fr.json. Foundry does not fall back to English for a missing key in the active non-English language — localize() just returns the raw key string (e.g. "BOILERPLATE.Sheet.Foo") if it's missing from the active language file.