RegistryAdding a languageMenu

Adding a language

Every block is i18n-native. A new language is a folder of message files — no component changes.

Each block reads its copy through next-intl under a namespace named after the block, and ships messages/en/<block>.json. The scaffold’s i18n/request.ts merges every file in messages/<locale>/ by filename, so the namespace is the filename.

Languages the registry ships

Every block also ships messages/mn/<block>.json, its Mongolian copy, kept to the English keys and ICU arguments by an architecture test. Start an app in both with:

Terminal
pnpm dlx @intelligo-dev/cli create my-app --locales mn,en

The first locale is the default. intelligo sync updates a shipped translation the way it updates English: a value you have not changed takes the new release’s text, and one you reworded is kept.

The blocks are laid out left to right. A right-to-left language can be translated, but the layouts are not mirrored for it in this release.

Add a locale

  1. Add it to i18n/routing.ts. The scaffold writes:

    i18n/routing.ts
    export const routing = defineRouting({
      locales: ["en"],
      defaultLocale: "en",
      // Locale prefix only appears in the URL when it isn't the default
      // locale (e.g. /dashboard, not /en/dashboard) — a single-locale
      // deployment needs nothing beyond this config and the shipped
      // English messages to work.
      localePrefix: "as-needed",
    });

    Add the locale to locales, for example ["en", "de"].

  2. For a language the registry ships (Mongolian, mn), there is nothing to copy: run intelligo sync, which installs every item’s messages/mn/ file beside the English one. For any other, copy messages/en/ to messages/de/ and translate the values. Keep the keys. You can translate a namespace at a time: i18n/request.ts lays each locale over the default locale’s messages, so a file or key de does not have yet renders in English.

  3. Install the language-switcher block and put it in a shell slot:

    TSX
    // lib/shell-config.tsx
    export const shellConfig: ShellConfig = { headerRight: LanguageSwitcher };

A missing file or key renders in the default locale; messages/en stays the reference, and intelligo sync --check lists what a locale has not translated.

Voice input in the composer recognises speech in the page’s language, the lang on <html> that the locale sets.

Emails

The emails the framework sends (the welcome, the verification link, the password reset, an invitation, the billing notices) are not pages, so they are not in the message files: they are written in English in the package. setEmailCopy from @intelligo-dev/core/email, bound in the composition root, is asked before each one goes out and may answer with its subject and its body in the recipient’s language; what it does not answer for is sent as written.

The resolver is given the language the recipient chose (locale, from users.preferred_language), which is null for an address with no account.

Notifications

A notification is stored once, in English, and shown many times. The notifications block writes each from its messages by type: types.<type>.title and types.<type>.message in notifications.json, filled from what the notification recorded, with amounts in the reader’s locale. The stored text shows for a type the messages do not name, so a notification of your own reads as you wrote it until you add its two keys:

messages/mn/notifications.json
{
  "types": {
    "digest_ready": {
      "title": "Тойм бэлэн боллоо",
      "message": "Энэ долоо хоногт {count, number} зүйл болсон байна."
    }
  }
}

A message may name the text and numbers in the metadata you passed to createNotification.

Your own strings

Add keys for your own routes to the relevant namespace — navigation labels go in messages/<locale>/app-shell.json, chat starters in chat.json — or add a new namespace file for a page of your own.

Blocks navigate through @/i18n/navigation, so links keep the active locale. Use the same helpers in your own pages instead of next/link.