Skip to content

Translations (bot + dashboard) ​

Phantom speaks 14 languages: English, French, Spanish, German, Romanian, Polish, Dutch, Chinese (Simplified), Arabic, Japanese, Korean, Russian, Portuguese (Brazil) and Hindi.

  • Bot language is per server: Guild Settings → Bot language (guild_settings.language). Every reply, embed, button, select menu, modal, autocomplete choice and DM the bot sends for that server goes out in that language, including tenant (custom-branded) bots and sidecar posts (streamer alerts, scheduled messages, trivia, birthdays). Slash-command descriptions are also registered with Discord's native localizations, which follow each member's own Discord app language. Discord has no Arabic client locale, so in the slash-command picker Arabic falls back to English. Replies are still in Arabic.
  • Dashboard language is per account: the language picker in the sidebar, on the account page and on the server picker (users.locale; signed-out visitors get a cookie, otherwise the browser's Accept-Language). Arabic switches the page to right-to-left.

How it works ​

Call sites keep writing plain English. Translation happens on the way out, against a catalog keyed by the English text:

SurfaceWhereWhat it translates
Botbot/src/i18n/interceptor.js wraps rest.requestmessage/interaction/webhook/modal/autocomplete payloads, per target server
Bot imagesbot/src/levelling/rank-card.jslabels drawn into the rank card PNG
Slash commandsbot/src/commands/builder.jsdescription_localizations, choice name_localizations
Dashboard HTML/JSONapp/Http/Middleware/Localize.phprendered pages, JSON toasts/errors/HTML fragments
Dashboard browserresources/js/i18n.jstext inserted after load, alert/confirm/prompt

Interpolated text is matched as a pattern: `Banned ${user} for ${reason}` is stored as Banned {0} for {1} and its captured values are translated recursively. Text with no catalog match (user content, server names) passes through unchanged. Every layer fails open: a translation error sends the English original.

Files ​

  • bot/src/i18n/source.json: bot strings, extracted from the code
  • lang/source/dashboard.json: dashboard strings, extracted from the views/config
  • lang/source/extra.json: hand-added strings (switcher UI, Laravel validation)
  • lang/translations/<lang>.json: the translations (English → target). Edit these.
  • Generated, do not edit: bot/src/i18n/locales/<lang>.json, lang/compiled/<lang>.php, public/i18n/<lang>.json

After changing user-facing text ​

sh
npm install                                 # acorn / acorn-walk (root devDependencies)
node scripts/i18n/extract-bot.cjs           # refresh bot/src/i18n/source.json
node scripts/i18n/extract-dashboard.cjs     # refresh lang/source/dashboard.json
node scripts/i18n/missing.cjs fr            # list strings fr has no translation for
# add translations to lang/translations/<lang>.json, then:
node scripts/i18n/build.cjs                 # regenerate the runtime files

New strings that nobody has translated yet simply show in English until they are added, so nothing breaks in the meantime.

Rules for translations: keep {0}-style placeholders, {user}-style template variables, Discord markdown, mentions (<@{0}>), slash commands, URLs and brand names (Phantom, Discord, Twitch, …) exactly as in the source.

Marketing site (SEO) ​

  • /languages: English hub for English searches ("French Discord moderation bot", "multilingual Discord bot"), with a section per language.
  • /fr, /es, /de, …: one landing page per language, written natively for local searches. Copy lives in lang/marketing/<code>.json (en.json is the template and fallback). {price_monthly}/{price_yearly} are filled from config/premium.php.
  • The home page and the landing pages form one hreflang cluster (rendered by partials/marketing/_hreflang, and with xhtml:link alternates in /sitemap.xml). x-default is the home page.
  • Structured data declares every supported language (inLanguage on the SoftwareApplication). /llms.txt gives AI crawlers a plain-text summary, generated from the same config. robots.txt names the major AI crawlers.
  • Adding a language: add it to Languages::ALL and the route constraint in routes/web.php, write lang/marketing/<code>.json, and add the flag SVG.
  • Header and footer on the language pages: the partials stay English; the layout translates their rendered HTML from lang/marketing/nav/<code>.json (App\Support\I18n\MarketingNav). After changing header/footer text, run php scripts/i18n/extract-marketing-nav.php to refresh lang/marketing/nav/source.json, then add the new strings to each language file (missing ones simply show in English). Text that JavaScript inserts must come from markup (see the hidden status-pill labels).

Trivia ​

Trivia questions are localized separately from the string catalog, because they're data (names, answers, word lists) rather than UI text.

  • bot/src/trivia/i18n/<lang>.json holds, per language: the prompt templates, the localized names of every country, city, continent, currency and landmark, the translated general-knowledge questions with their answers, and a native word list for unscramble (empty for zh, ja and hi, where unscramble steps aside).
  • node scripts/i18n/extract-trivia.cjs rebuilds source.json from bot/src/trivia/data/; translate what changed into each language file (or into parts/<lang>.geo.json / parts/<lang>.general.json and run node scripts/i18n/merge-trivia.cjs). bot/tests/trivia-i18n.test.js fails if a language is missing anything.
  • A localized question accepts the local answers and the English ones.
  • Answer matching is Unicode-aware. bot/src/trivia/answer-fold.json (built by scripts/i18n/build-answer-fold.cjs) is shared by the bot's answer-matcher.js and the dashboard's TriviaController::normaliseAnswer(), and bot/tests/fixtures/trivia-normalise.json is asserted on both sides.
  • Shared-bank multiple-choice rows get a translations column filled by the sidecar's top-up job. A non-English guild only draws rows already translated into its language. Flags are localized via the pack. Custom questions are served exactly as the guild wrote them.

Phantom is a product of Hydra Labs. The bot is run as a managed service; you do not need to host it yourself.