Adding a New Locale
This guide walks through adding support for a new display language in TomoriBot.
-
Create
src/locales/{locale}/directory. Copy the file/folder structure fromsrc/locales/en-US/— the top-level.tsfiles (bridges.ts,commands.ts,general.ts,providers.ts,tools.ts) plus thecommands/sub-folder with one file per command category.en-USis the canonical reference for key structure. -
Ensure every required key exists in the new file. Missing keys will cause
check-localesto fail. -
initializeLocalizer()auto-discovers locale files at startup — no manual registration is needed. -
Run
bun run check-localesto verify key parity across all locale files.
- Keys follow dot-notation:
commands.{category}.{subcommand}.{key} - Auto-localization for command options uses specific key patterns — see
docs/subsystems/localization.mdfor the full naming convention. - The locale scanner reads comments too. If a comment contains a locale key example, write it
in split form (
"m.room" + ".message") rather than joined — the scanner will otherwise count it as a real key and flag false parity failures.
Quality Gate
Section titled “Quality Gate”bun run check-locales # verify key parity across all locale filesbun run check # TypeScript strict modebun run lint # Biome formattingRelated Docs
Section titled “Related Docs”docs/subsystems/localization.md— key naming,localizer()API, locale discovery