OmegaBot uses i18n in src/i18n/index.ts for rate limits and errors. Cooldown messages respect guild locale (en/es/de).
- Current Status
- Usage
- Adding Translations
- Variable Substitution
- Extending Locales
- Wired Into Commands
- English (en) – Default locale; all keys have translations
- Spanish (es) – Common strings translated
- German (de) – Common strings translated
import { t, resolveLocale } from "../i18n/index.js";
// Simple lookup (uses default locale)
const msg = t("rate_limit.try_again", "en", { seconds: 5 });
// → "Try again in 5s"
// With guild locale (e.g. from interaction.guild?.preferredLocale)
const locale = resolveLocale(interaction.guild?.preferredLocale);
const msg2 = t("error.generic", locale);- Add the key to
translations.eninsrc/i18n/index.ts - Add translations for
esandde(or leave empty to fall back to English) - Use
t(key, locale, vars)in your code for variable substitution
Keys can use {variableName} placeholders:
"rate_limit.try_again": "Try again in {seconds}s"
t("rate_limit.try_again", "en", { seconds: 10 }) // → "Try again in 10s"
To add a new locale (e.g. French):
- Add
"fr"to theLocaletype - Add
fr: { ... }to thetranslationsobject - Update
resolveLocale()to support guild/user locale preference (e.g. fromguild_configor Discord's locale)
- Rate limits:
formatCooldownMessage()usest("rate_limit.cooldown_full", locale)withinteraction.guild?.preferredLocale - Generic errors: Interaction handler uses
t("error.generic", resolveLocale(guildLocale))on command failure