Translations & Internationalization (i18n)
JetPack provides first-class, zero-dependency internationalization across the native daemon (jetpack-daemon), Control Center (http://127.0.0.1:9470), the @jetpack-desktop/client frontend SDK, sandboxed Python workers (jetpack_sdk), and standalone applications.
By design, English ("en") is always the default and universal fallback language:
- Fresh installations default to
"en". - Supported native platform locales currently include English (
en) and Ukrainian (uk). - If an application does not support the user's selected daemon language, it automatically falls back to
"en"without broken keys, raw placeholders, or runtime errors.
1. How Language Selection & Propagation Works
Users pick their preferred language in Control Center under My Hardware & Security (#security) → Language.
When the user switches the language:
- Daemon Persistence & Live Tray Refresh: Control Center invokes
client.set_language(lang)over the encrypted WebSocket control plane (settings.set).jetpack-daemonpersistslanguagein encryptedpaired_clients.dband immediately rebuilds the live OS tray menu (TrayEvent::LanguageChanged) and nativerfd/wrydialogs/titles—no restart required. - Launch URL Propagation (
?lang=): Every app opened from Control Center, the OS tray Launch / Open menu, orui.open_urlappends?lang=<active_language>to the destination URL (preserving existing query parameters and URL fragments). For externalhttps://launch_urlcatalog entries,SignedAppCatalogorigin validation still permits appending a validated?lang=query parameter without invalidating Ed25519 signatures. - WASM &
@jetpack-desktop/clientResolution: Inside any frontend usingJetPackAppClient.connectAndEnsureApp(), the active language resolves deterministically in order:- Explicit
controlBar.languageoverride (if provided) - URL query parameter
?lang=<code>(normalized, e.g.uk-UA→uk) DaemonSettings.languagereturned bysettings.get- Default fallback
'en'
- Explicit
- Worker Environment Injection (
JETPACK_LANG): Before entering the OS kernel sandbox (AppContaineron Windows,Seatbelton macOS,bwrap+ Landlock on Linux),jetpack-daemoninjectsJETPACK_LANG=<language>into the worker process environment, overriding any static manifestexecution.enventry. Inside Python workers, readclient.language.
2. Managing Translation Catalogs with jetpack i18n
The console jetpack CLI manages flat JSON translation catalogs under locales/ in pure Rust (zero Node or Python runtime dependencies across windows/amd64, darwin/arm64, and linux/amd64).
Quick Start Commands
# 1. Create canonical base catalog locales/en.json
jetpack i18n init .
# 2. Add a secondary locale seeded cleanly from locales/en.json
jetpack i18n add uk .
# 3. Validate JSON structure, key parity, orphan keys, and {placeholder} tokens
jetpack i18n check . --strict
# 4. Sync secondary catalogs when en.json adds/removes keys (--prune drops stale keys)
jetpack i18n sync . --pruneScaffolding & npm Scripts
Every new project created with jetpack init (or jetpack-daemon --init-app, or the scaffold_app MCP tool) includes:
.agents/skills/add-translations/SKILL.md— Step-by-step Agent Skill workflow for adding new languages safely.package.jsoncross-platform scripts:npm run i18n:check→jetpack i18n check .npm run i18n:sync→jetpack i18n sync .
- In
--template fullstack: starterlocales/en.json,"resolveJsonModule": trueintsconfig.json, andsrc/main.tspre-wired withcreateI18n+client.onLanguageChanged(...).
Catalog Format Rules
locales/en.jsonis the canonical source of truth.- Each
locales/<lang>.jsonfile MUST be a flat JSON object mapping non-empty string keys to string values (Record<string, string>). Nested objects, arrays, numbers, andnullvalues failjetpack i18n check. <lang>is validated and normalized to its lowercase ASCII primary BCP-47 subtag (e.g.uk-UA→uk). Path separators (/),.., control characters, and overly long tags are rejected.{placeholder}tokens (for example{count},{error}) MUST match identically betweenen.jsonand every secondary catalog.- Never place translation catalogs under
.agents/or.cursor/—when runningjetpack packageorjetpack install-local, AI DX folders are stripped whilelocales/andui/locales/are cleanly included in the OCI layer.
3. Frontend Localization (@jetpack-desktop/client)
@jetpack-desktop/client exports zero-dependency i18n helpers so standalone Vite/TypeScript apps share the same normalization, placeholder interpolation, and fallback rules as Control Center:
import {
JetPackAppClient,
createI18n,
resolveLanguage,
} from '@jetpack-desktop/client';
import enMessages from '../locales/en.json' with { type: 'json' };
import ukMessages from '../locales/uk.json' with { type: 'json' };
const i18n = createI18n({
catalogs: {
en: enMessages,
uk: ukMessages,
},
initialLocale: resolveLanguage({
supportedLocales: ['en', 'uk'],
}),
});
function renderUi() {
document.documentElement.lang = i18n.getLocale();
document.getElementById('title')!.textContent = i18n.t('app.title');
document.getElementById('echo')!.textContent = i18n.t('result.echo', { bytes: 128 });
}
i18n.onChange(() => renderUi());
const client = new JetPackAppClient();
client.onLanguageChanged((lang) => {
const supported = resolveLanguage({
preferredLanguage: lang,
supportedLocales: i18n.getSupportedLocales(),
});
i18n.setLocale(supported);
});
await client.connectAndEnsureApp({
appId: 'com.dev.my-app',
daemonPort: 9470,
});
renderUi();Built-in Shadow-DOM Chrome
Both JetPackControlBar (including status pills, Control Center / Download JetPack links, the unified context-aware Launch / Stop button, the stop confirmation modal, and the install-gate overlay) and JetPackLogTerminal automatically localize into 'en' or 'uk' based on the resolved session language (falling back to 'en' for unsupported languages), and can also be switched dynamically via bar.setLanguage(lang) or terminal.setLanguage(lang).
4. Python Worker Localization (jetpack_sdk)
Inside any sandboxed Python worker, JetPackClient.language exposes the daemon's active language from JETPACK_LANG, normalized to a safe lowercase primary tag with automatic "en" fallback:
from jetpack_sdk import JetPackClient
MESSAGES = {
"en": {"done": "Processed {count} item(s)."},
"uk": {"done": "Оброблено елементів: {count}."},
}
with JetPackClient() as client:
lang = client.language if client.language in MESSAGES else "en"
summary = MESSAGES[lang]["done"].format(count=4)Notice that if the worker receives an unsupported locale (for example fr), falling back to "en" guarantees predictable English output.
5. AI Agent Skill (add-translations)
When using an AI coding agent (Claude Code, Cursor, Windsurf, OpenClaw) inside a scaffolded JetPack project, ask it to use .agents/skills/add-translations/SKILL.md. The skill guides the agent through:
- Creating or checking
locales/en.jsonas the English base catalog. - Adding target locales via
jetpack i18n add <lang>. - Translating every key while preserving
{placeholder}names. - Wiring
createI18n,resolveLanguage,client.onLanguageChanged, and optionalclient.languagein Python. - Running
jetpack i18n check . --strict,npm run typecheck, andnpm run packageto verify bundle integrity.
