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 viaIntl.PluralRules),{k, select, a {..} other {..}}. Escape literal braces as\{and\}.otheris 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")fromi18n/dom.js. They tag the element withdata-i18n*andtranslateDom()(called on every locale change) re-translates it. Plain HTML may usedata-i18n,data-i18n-title,data-i18n-aria-label,data-i18n-placeholder,data-i18n-tipdirectly. - The app emits
localeon theAppbus (app.on("locale", fn)), andapp.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.registerCommandturnslabelinto a getter that callst(), 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 inui/controls.js, toasts): plain English literals are passed throught()when rendered. The extractor knows these tables throughIMPLICITrules at the top ofscripts/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#
cp app/src/i18n/locales/en.json app/src/i18n/locales/<code>.jsonand translate the values (keep placeholders and plural structure; leave entries untranslated by deleting them, they fall back to English).- Add one entry to
LOCALESinapp/src/i18n/locales.js(code,tag,namein its own language,englishName,url). npm run i18n:check(also part ofnpm test). Optional:node scripts/i18n-extract.mjs --missing <code>.- Add the new terms to the glossary.
Settings ▸ General ▸ Language lists LOCALES automatically.
Tooling#
npm run i18n:extractrewriteslocales/en.jsonfrom the sources and prints per-locale coverage.npm run i18n:check(CI,tests/i18n/catalog.test.js) fails whenen.jsonis stale, a locale has keys that are not in the catalog, placeholders differ from English, a plural has nootherbranch or the syntax is invalid.--strictalso fails on untranslated keys;--missing <code>lists them. Dynamict()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) andui/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 fromcore/andengine/(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), localizeddocs/and the README. - OS locale from the Tauri shell: the webview's
navigator.languagesalready follows the OS;platform.osLocale()is an optional hook that no platform implements yet.
Edit on GitHub → docs/i18n.md