feat(plugins): a plugin's own translations (i18n contract) and the i18n.read bridge #45

Closed
gabrielvidal wants to merge 0 commits from auto-translate into main
pull from: auto-translate
Owner

Summary

A plugin can now carry its own translated strings in a shared format, and the hub reports what each plugin and each translation is missing. This is what the auto-translate plugin (ai-agent-plugins #34) reads to keep translations up to date. Decided in form auto-translate-plugin_ovprq0.

Merge after #38 and #39: this branch sits on top of both, so until they are merged the diff here shows their commits too.

Key changes

  • backend/plugins/plugin_i18n.py: the contract. A plugin declares "i18n": "i18n"; the folder holds en.json (the English source list) and one <lang>.json per language. The hub adds every language that has a file to the plugin's languages.
  • GET /api/plugins/i18n/{lang}: the caller's active plugins' dictionaries in one call (ETag). A guest gets their own installs and the managed plugins granted to them, nothing else.
  • Frames get their plugin's dictionary as init.i18n and translate with aiAgentPlugin.t() / tn(); the device keeps a copy. Manifest labels use the plugin's dictionary, then the core's, then English. Handlers get the installed languages (AIA_LANGS).
  • backend/plugins/hubi18n.py: an owner-only bridge, i18n.read, that reports from files only what each translation and each plugin is missing or holds stale.
  • A plugin's page shows, per language, how many strings it has and how many are missing or stale.
  • workers.read also says when a machine was last seen and whether a run wakes it (about ten lines in plugins/hubruns.py), so a plugin can tell an asleep machine from a gone one.

Key decisions

  • English text is the key, as in the core, so a reworded English string shows as one missing and one stale entry instead of silently keeping an outdated translation.
  • Plugins with inline French keep working untouched. The contract is opt-in; three plugins move to it in ai-agent-plugins #34 as references.
  • Anything missing shows in English, never an empty label.

Changelog

  • Added: plugins can ship their own translations as i18n/<lang>.json, and each plugin's page shows what is missing per language.

Test notes

  • Backend: 172 modules, each in its own bwrap sandbox; all pass except test_typed_plugins when run from ~/worktrees (it passes from a copy elsewhere; same on the base). I re-ran test_plugin_i18n (14), test_i18n (35), test_authz_matrix (2), test_plugin_categories (8) and test_gate (15): all pass.
  • Frontend: tsc clean; vitest 1105 of 1107. FreshContext fails the same way on main; reachability is flaky (passed twice, failed once alone) and is not touched by this diff.
  • Live local hub: a guest's cron-jobs page renders in French from i18n/fr.json; coverage rows on a plugin's page (screenshots below).
  • Deploy from the Homelab, before ai-agent-plugins #34 is reloaded. Not deployed from the EVOX2.

Screenshots

desktop-plugin-coverage.png
guest-cron-fr.png

## Summary A plugin can now carry its own translated strings in a shared format, and the hub reports what each plugin and each translation is missing. This is what the `auto-translate` plugin (ai-agent-plugins #34) reads to keep translations up to date. Decided in form `auto-translate-plugin_ovprq0`. **Merge after #38 and #39**: this branch sits on top of both, so until they are merged the diff here shows their commits too. ## Key changes - `backend/plugins/plugin_i18n.py`: the contract. A plugin declares `"i18n": "i18n"`; the folder holds `en.json` (the English source list) and one `<lang>.json` per language. The hub adds every language that has a file to the plugin's `languages`. - `GET /api/plugins/i18n/{lang}`: the caller's active plugins' dictionaries in one call (ETag). A guest gets their own installs and the managed plugins granted to them, nothing else. - Frames get their plugin's dictionary as `init.i18n` and translate with `aiAgentPlugin.t()` / `tn()`; the device keeps a copy. Manifest labels use the plugin's dictionary, then the core's, then English. Handlers get the installed languages (`AIA_LANGS`). - `backend/plugins/hubi18n.py`: an owner-only bridge, `i18n.read`, that reports from files only what each translation and each plugin is missing or holds stale. - A plugin's page shows, per language, how many strings it has and how many are missing or stale. - `workers.read` also says when a machine was last seen and whether a run wakes it (about ten lines in `plugins/hubruns.py`), so a plugin can tell an asleep machine from a gone one. ## Key decisions - **English text is the key**, as in the core, so a reworded English string shows as one missing and one stale entry instead of silently keeping an outdated translation. - **Plugins with inline French keep working untouched.** The contract is opt-in; three plugins move to it in ai-agent-plugins #34 as references. - **Anything missing shows in English**, never an empty label. ## Changelog - Added: plugins can ship their own translations as `i18n/<lang>.json`, and each plugin's page shows what is missing per language. ## Test notes - Backend: 172 modules, each in its own bwrap sandbox; all pass except `test_typed_plugins` when run from `~/worktrees` (it passes from a copy elsewhere; same on the base). I re-ran `test_plugin_i18n` (14), `test_i18n` (35), `test_authz_matrix` (2), `test_plugin_categories` (8) and `test_gate` (15): all pass. - Frontend: `tsc` clean; vitest 1105 of 1107. `FreshContext` fails the same way on `main`; `reachability` is flaky (passed twice, failed once alone) and is not touched by this diff. - Live local hub: a guest's cron-jobs page renders in French from `i18n/fr.json`; coverage rows on a plugin's page (screenshots below). - **Deploy from the Homelab, before ai-agent-plugins #34 is reloaded.** Not deployed from the EVOX2. ## Screenshots ![desktop-plugin-coverage.png](https://git.gabvdl.xyz/attachments/89e01eb9-9769-470b-9523-47a6e22a3d3e) ![guest-cron-fr.png](https://git.gabvdl.xyz/attachments/8756fde4-00ef-4c2e-b133-3469381d80ce)
gabrielvidal self-assigned this 2026-11-28 20:20:34 +01:00
gabrielvidal added 4 commits 2026-11-28 20:20:34 +01:00
The core speaks English only; every other language is a kind: "translation" plugin
(translation-<lang>; the French one is translation-fr in ai-agent-plugins, seeded once at start).

- plugins: kind translation (typed_manifest.parse_translation: lang, name, englishName, flag,
  locale, promptLine, ui/backend JSON dictionaries — strict, operator-only, in the fingerprint);
  a top-level "languages" field on any plugin (default ["en"]) shown on its page; seeding takes
  translation-*; plugins/translations.py reads the enabled ones (first by id wins a code).
- core/i18n: tr / langs / localized / clean_pref / effective_lang read the installed
  translations; a pick whose translation is gone reads English and is kept; browserLang records
  any base code. core/i18n_fr.py and FRENCH_LINE are gone (language_line = the plugin's promptLine).
- The owner picks a language too (users.json ownerLang, PUT /api/me {lang}; English by default).
- Public GET /api/i18n/languages and /api/i18n/{lang} (ETag/304), guest host and sign-in included.
- Coverage: backend/core/i18n_keys/{ui,backend}.json (kept by the two i18n tests,
  UPDATE_I18N_KEYS=1); a translation's page shows translated / missing / stale / placeholder
  mismatches.
- Frontend: frontend/src/i18n/fr removed; the dictionary comes from the hub, cached in
  localStorage and revalidated in the background (first boot in a language waits <= 4 s, any
  failure is English); Lang is a string; number/currency style from the translation's locale;
  LanguageSelect lists English + installed translations (hidden when none); Settings → Plugins
  has a Translations kind (tab, catalog filter, group) and a Translation section with the
  missing-strings count; mock is English only.
- Tests: test_i18n.py rewritten on a made-up translation; i18n_testkit.speaking() for the
  tests that need a second language. authz golden, openapi.json + src/generated regenerated;
  docs/plugins.md (Translations), CLAUDE.md, i18n README, docs/settings.md.

Changelog
- Added: languages are plugins — Settings → Plugins → Translations; the owner can pick a language.
- Changed: French moved to the translation-fr plugin (seeded at start: nothing changes for guests).
- Removed: the core's built-in French dictionaries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Orca's layout in the app's own look (form plugins-page-rework_rhce3j): a
category sidebar with counts (a chip row on a phone), search, All / Installed /
Available, a sort (Installed first, Name, Recently updated — per person), and
cover cards or compact rows (the grid / list toggle is kept).

- New manifest field `category` (backend/plugins/categories.py), strict: an
  app picks dev, data, agents, chat, scheduling, media or other (the
  default); a provider / harness / translation sits under its kind's shelf.
  Not in the approval fingerprint. Every row of GET /api/plugins carries the
  resolved category; a record from before the field reads its source's
  plugin.json.
- Translations works as soon as the translation kind exists; an empty
  category is hidden.
- ?cat= / ?show= addresses; the old ?tab= / ?kind= links still land.
- Docs: docs/plugins.md → "Categories and the Plugins page", CLAUDE.md.

Deploy this before installing ai-agent-plugins' plugin-categories branch:
an older core refuses the unknown `category` key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A plugin's translations now live in that plugin: "i18n": "i18n" in plugin.json
→ i18n/en.json (the English source list, generated by the plugins repo's
scripts/plugin_i18n.py) + i18n/<lang>.json (English → translation).

- plugins/plugin_i18n.py: validation (the folder, en.json an array, each
  <lang>.json an object; every file's language added to `languages`),
  per-language coverage (missing / stale / placeholder mismatches), the bundle.
- GET /api/plugins/i18n/{lang}: every active plugin's dictionary in one ETag'd
  body (a guest: their installs + the managed plugins granted to them).
- Frames: init.i18n + init.locale, aiAgentPlugin.t / tn (English fallback).
- Manifest labels (nav, drawers, header, Files/Projects/Dashboards, settings
  subtitle + fields) through pluginT: plugin dictionary → core t() → English.
- Handlers get AIA_LANGS (the hub's languages); they read their own file.
- /api/plugins/{id}/info|settings carry `i18n` coverage; the plugin page shows
  "Its strings in <language>" rows.
- plugins/hubi18n.py: the owner-only i18n.read bridge (operator approval) —
  translations' and plugins' coverage, files only — for the auto-translate plugin.
- docs/plugins.md ("A plugin's own strings"), CLAUDE.md, i18n README; openapi +
  generated types, authz golden, ui key list regenerated.

Changelog
- Added: plugins can ship their own translations (i18n/<lang>.json), shown per language on their page.
- Added: the i18n.read bridge the auto-translate plugin uses to keep translations complete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For the auto-translate plugin, whose daily run is pinned to the EVOX2 (often
asleep): a run pinned to an offline worker is refused 409 worker_offline unless
the machine.wake plugin has it on auto-wake (route_new_run wakes it and waits
up to its timeout). The plugin now reads that up front to retry and to say so.

- plugins/hubruns.workers_payload: each machine row adds lastSeen, autoWake and
  wakeTimeoutSec (machine_wake.list_wakeable, cached 30 s); a test.
- docs/plugins.md: the workers.read line.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner
Merged into `main` as 1365b6aa by the auto-ship batch https://ai-agent.lab.gabvdl.xyz/conversation/cadefe6f-0940-4688-bc56-1306d9265430.
gabrielvidal closed this pull request 2026-11-28 21:10:26 +01:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gabrielvidal/ai-agent#45