Skip to content

feat(i18n): add opt-in data-only UI locale extensions - #41

Closed
Xianbei233 wants to merge 2 commits into
TannerMidd:mainfrom
Xianbei233:feat/ui-locales
Closed

Xianbei233 wants to merge 2 commits into
TannerMidd:mainfrom
Xianbei233:feat/ui-locales

Conversation

@Xianbei233

Copy link
Copy Markdown

Summary

Add a generic, opt-in UI localization capability to drop-in extensions, without shipping any language dictionary in Pocket itself.

  • PocketExtension.uiLocales: validated, copied/frozen plain dictionaries and named-placeholder templates.
  • Deliver enabled packs only in authenticated hello / /api/me; no public dictionary endpoint or browser-side extension scripts.
  • Explicit t(source) / t(template, params) call sites across existing UI. Parameters are inserted once as text; user messages, names, paths, model/provider identifiers and raw errors stay unchanged.
  • English fallback with no enabled pack; deterministic default/tag selection; no saved or per-user language preference.
  • Lifecycle follows extension enable/disable/edit/delete, with client refresh, stale-load protection, and failed-reload validation before registry publication.
  • Documentation and isolated loader/runtime/browser tests, including live updates in already-open guest menus at phone and desktop sizes.

Based on current upstream 45685e1 (0.12.1). This branch does not include model routing, context compression, local settings, or the Chinese dictionary. The independently distributed example pack is https://github.com/Xianbei233/pi-pocket-zh-cn .

Scope and limitations

This is explicit call-site coverage, not a DOM-wide replacement pass or a claim of complete localization. New 0.12-specific surfaces may still be English. Service-worker/server push payloads and unauthenticated pages are not localized. Locale extensions remain trusted server-side code, like every other drop-in; only their validated dictionary data goes to the browser.

Validation

All runs used temporary data and scripted models; no live service restart, dependency installation, or build.

  • npm run check: pass.
  • npm run format:check: pass (Prettier + ESLint).
  • JavaScript syntax checks on changed files: pass.
  • Targeted runtime/loader/drop-in tests: 17/17 pass.
  • Browser locale integration: pass at phone and desktop sizes, preserving the user title, draft, model identifier and open route while enabling/disabling without a document reload.
  • Actual independent Chinese pack loader smoke test: pass (679 static strings, 91 templates).
  • Full npm test: 350/351 pass, twice. The sole failure is the existing timing-ratio test a long session with many compactions reads in time that grows with its length in test/pi-sessions.test.ts (8.1x / 9.0x).
  • Control run on unmodified upstream 45685e1: 336/337, failing the same timing test (9.6x). The isolated test/pi-sessions.test.ts rerun passes 18/18. The performance test and implementation are unchanged in this PR.
  • A serial full-suite attempt hit a 240-second command timeout before completion; it is not counted as a passing full run.

The older 0.11-compatible branch is retained separately for existing deployments; no old-UI overwrite was used to resolve the 0.12 port.

@Xianbei233

Copy link
Copy Markdown
Author

Closing this original proposal because it has been superseded by the clean replacement PR #64: #64.

@Xianbei233 Xianbei233 closed this Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant