OpenFini

Docs / Guides

Internationalization (i18n)

OpenFini ships in US English and German; the language is chosen automatically from the system and can be changed in Settings ▸ General ▸ Language. Decision record: ADR 0007. Terms: glossary.

Architecture#

app/src/i18n/
  index.js     t(), N_(), initI18n, setLocale, onLocaleChange, translateDom, Intl helpers   (runtime)
  format.js    ICU-lite parser/formatter, validateMessage, placeholders                      (pure, tested)
  detect.js    locale detection order, tag matching, text direction                          (pure, tested)
  dom.js       ta({...}) translated attributes, tspan(text) for UI built once               (DOM helpers)
  locales.js   LOCALES: the single list of languages
  locales/     en.json (generated catalog, reference) and <code>.json (translations)
app/src/extensions/i18n.js   %key% placeholders in extension manifests (pure, tested)
scripts/i18n-extract.mjs     extraction + check (npm run i18n:extract / i18n:check)
tests/i18n/                  unit tests + the catalog CI guard

Detection order: ?lang= override, then the language preference ("auto" by default), then navigator.languages (first supported one; de-AT and de-CH match de), then the OS locale from the platform layer (optional), then en. <html lang> and dir follow the locale (RTL is wired but no RTL language exists yet). Only the active language is loaded.

Fallback chain: translation -> English text (the key, or the default given with an explicit id).

Dev flags: ?lang=de forces a language, ?i18n=keys shows keys instead of text, ?navlang=de-DE,en pretends navigator.languages has those values (test hook that needs no desktop shell).

Wrapping strings#

import { t, N_ } from "../i18n/index.js";
t("Save As…");                                    // English text is the key
t("Open {name}", { name });                       // named placeholder
t("{n, plural, one {# page} other {# pages}}", { n }); // plural, "#" = the number (formatted for the locale)
t("menu.file", "File");                           // explicit id for ambiguous strings
const LABEL = N_("Undo");                         // static data: mark now, call t(LABEL) when rendering
  • Syntax: {name}, {n, plural, =0 {..} one {..} other {..}} (CLDR categories via Intl.PluralRules), {k, select, a {..} other {..}}. Escape literal braces as \{ and \}. other is mandatory.
  • Never build sentences from fragments; use placeholders. Never wrap user data.
  • Calling t() must happen when the text is shown, not at module load, so a language switch can update it.
  • Built-once UI (header, buttons): use ta({ "aria-label": "Undo", tip: "Undo" }) / tspan("Export") from i18n/dom.js. They tag the element with data-i18n* and translateDom() (called on every locale change) re-translates it. Plain HTML may use data-i18n, data-i18n-title, data-i18n-aria-label, data-i18n-placeholder, data-i18n-tip directly.
  • The app emits locale on the App bus (app.on("locale", fn)), and app.i18n.locale() / .t() / .set() are available. Components that cache rendered text should re-render on that event (menus, command labels, the settings dialog, the status bar, the welcome screen and the studio bar already do).

What is translated automatically#

  • Command labels: App.registerCommand turns label into a getter that calls t(), so menus, the palette, shortcut lists and tooltips are translated at read time.
  • Menu tables, tour steps, What's new, studio blurbs, settings schema, dialog helpers (openDialog, confirmDialog, form fields in ui/controls.js, toasts): plain English literals are passed through t() when rendered. The extractor knows these tables through IMPLICIT rules at the top of scripts/i18n-extract.mjs; add a rule when you add a similar table. Literals with a different shape (template strings with user data) stay English.

Adding a language#

  1. cp app/src/i18n/locales/en.json app/src/i18n/locales/<code>.json and translate the values (keep placeholders and plural structure; leave entries untranslated by deleting them, they fall back to English).
  2. Add one entry to LOCALES in app/src/i18n/locales.js (code, tag, name in its own language, englishName, url).
  3. npm run i18n:check (also part of npm test). Optional: node scripts/i18n-extract.mjs --missing <code>.
  4. Add the new terms to the glossary.

Settings ▸ General ▸ Language lists LOCALES automatically.

Tooling#

  • npm run i18n:extract rewrites locales/en.json from the sources and prints per-locale coverage.
  • npm run i18n:check (CI, tests/i18n/catalog.test.js) fails when en.json is stale, a locale has keys that are not in the catalog, placeholders differ from English, a plural has no other branch or the syntax is invalid. --strict also fails on untranslated keys; --missing <code> lists them. Dynamic t() keys are reported as warnings.
  • Changing an English string changes its key: run i18n:extract, then update the translations.

Extensions#

A manifest may use %key% for any string in name, description and contributes. The values come from the package's optional locales/<code>.json ({"key": "Text"}), looked up by exact tag, base language, then en.json, then the key. Resolution is applied when an extension is loaded, so a language change shows in extension menus after the extension is reloaded or the app restarted. Exposing openfini.i18n inside the extension sandbox is not done yet.

Vibe#

buildSystemPrompt({ language }) receives app.i18n.locale(): replies follow the UI language unless the user writes in another one. Built-in skills, tool descriptions and system instructions stay English (they are instructions to the model).

Web specifics#

index.html keeps lang="en-US" (updated at run time), the <noscript> text is bilingual, and the service worker's offline page picks English or German from navigator.languages. The Windows installer is localized separately (see installer docs).

Known gaps (unwrapped areas, continue here)#

  • Settings sections from ui/security-center.js, ui/customize/* (keyboard editor, toolbox editor, workspaces, profiles) and ui/studio-settings.js, ui/theme-gallery.js, theme names.
  • The slice/website/publish tabs of the Export dialog (ui/export-*.js; the Image & PDF tab is translated), import dialogs (ui/import-dialogs.js), app lock, diagnostics and troubleshooting dialogs (ui/app-lock.js, ui/diagnostics-dialog.js).
  • Panels and tools: Layers, Properties, Brush, Color, Histogram, History, tool names and option bars, effect and filter names (app/src/ui/*panel*, app/src/studios/tools/, app/src/engine/), the Code studio UI (ui/code/), Data/Git/Publish panels.
  • Vibe studio panels (Models, Tools, Skills, Knowledge, Activity, tool cards) except the composer; Vibe tool result text.
  • Context menu providers outside ui/context-menu/providers.js, error messages thrown from core/ and engine/ (shown as written), toasts built from template strings, help-content.js ("What's this?" texts), onboarding of extensions UI.
  • The extension sandbox API (openfini.i18n), localized docs/ and the README.
  • OS locale from the Tauri shell: the webview's navigator.languages already follows the OS; platform.osLocale() is an optional hook that no platform implements yet.

Edit on GitHub → docs/i18n.md