---
url: https://jetpack-desktop.github.io/guide/translations.md
description: >-
  Localize JetPack desktop apps and Control Center with English-first fallbacks,
  createI18n, JETPACK_LANG in Python workers, jetpack i18n CLI commands, and the
  add-translations Agent Skill.
---

# 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:

1. **Daemon Persistence & Live Tray Refresh**: Control Center invokes `client.set_language(lang)` over the encrypted WebSocket control plane (`settings.set`). `jetpack-daemon` persists `language` in encrypted `paired_clients.db` and immediately rebuilds the live OS tray menu (`TrayEvent::LanguageChanged`) and native `rfd` / `wry` dialogs/titles—no restart required.
2. **Launch URL Propagation (`?lang=`)**: Every app opened from Control Center, the OS tray **Launch / Open** menu, or `ui.open_url` appends `?lang=<active_language>` to the destination URL (preserving existing query parameters and URL fragments). For external `https://` `launch_url` catalog entries, `SignedAppCatalog` origin validation still permits appending a validated `?lang=` query parameter without invalidating Ed25519 signatures.
3. **WASM & `@jetpack-desktop/client` Resolution**: Inside any frontend using `JetPackAppClient.connectAndEnsureApp()`, the active language resolves deterministically in order:
   1. Explicit `controlBar.language` override (if provided)
   2. URL query parameter `?lang=<code>` (normalized, e.g. `uk-UA` → `uk`)
   3. `DaemonSettings.language` returned by `settings.get`
   4. Default fallback `'en'`
4. **Worker Environment Injection (`JETPACK_LANG`)**: Before entering the OS kernel sandbox (`AppContainer` on Windows, `Seatbelt` on macOS, `bwrap` + Landlock on Linux), `jetpack-daemon` injects `JETPACK_LANG=<language>` into the worker process environment, overriding any static manifest `execution.env` entry. Inside Python workers, read `client.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

```bash
# 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 . --prune
```

### Scaffolding & `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.json` cross-platform scripts:
  * `npm run i18n:check` → `jetpack i18n check .`
  * `npm run i18n:sync` → `jetpack i18n sync .`
* In `--template fullstack`: starter `locales/en.json`, `"resolveJsonModule": true` in `tsconfig.json`, and `src/main.ts` pre-wired with `createI18n` + `client.onLanguageChanged(...)`.

### Catalog Format Rules

* `locales/en.json` is the **canonical source of truth**.
* Each `locales/<lang>.json` file MUST be a flat JSON object mapping non-empty string keys to string values (`Record<string, string>`). Nested objects, arrays, numbers, and `null` values fail `jetpack 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 between `en.json` and every secondary catalog.
* Never place translation catalogs under `.agents/` or `.cursor/`—when running `jetpack package` or `jetpack install-local`, AI DX folders are stripped while `locales/` and `ui/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:

```typescript
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:

```python
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:

1. Creating or checking `locales/en.json` as the English base catalog.
2. Adding target locales via `jetpack i18n add <lang>`.
3. Translating every key while preserving `{placeholder}` names.
4. Wiring `createI18n`, `resolveLanguage`, `client.onLanguageChanged`, and optional `client.language` in Python.
5. Running `jetpack i18n check . --strict`, `npm run typecheck`, and `npm run package` to verify bundle integrity.
