Files
Hy-Memory/memhub/docs/LOCALIZATION.md
366befc2aa feat(memhub): add extensible Chinese, English, and Spanish UI (#142)
* Add Spanish localization and persistent GUI language preferences to MemHub

Co-authored-by: Cursor <cursoragent@cursor.com>

* Extend MemHub Spanish localization to the remaining GUI screens

Move the copy of Applications, memory space and map, matters, workbench,
call history, handoff and arrival panels into shared contracts catalogs.

- Merge domain catalogs without silent overrides: a key shared by two
  catalogs must have identical Chinese and Spanish texts.
- Add Spanish singular variants (`.one`) and count helpers that keep the
  Chinese numbers exactly as they were rendered before.
- Build the Spanish connection prompt from a catalog template; MCP and
  shell snippets are inserted verbatim, the Chinese prompt is unchanged.
- Word host failures at render time so a language switch re-words them.
- Unknown text, names, paths and error codes pass through untranslated;
  unknown graph node types and edge origins keep their previous labels.
- Add catalog parity, interpolation, adapter and regression tests.

* feat(memhub): add Chinese English Spanish localization

Co-authored-by: Nicolas Pirello <nicoalepirello@gmail.com>

Co-authored-by: kristinhe <kristinhe@tencent.com>
Co-authored-by: Cursor <cursoragent@cursor.com>

* style(memhub): satisfy Node workspace lint

Co-authored-by: Cursor <cursoragent@cursor.com>

* test(memhub): align localization fixtures with current keys

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Nicolas Pirello <nicoalepirello@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: alvinfei <alvinfei@tencent.com>
Co-authored-by: kristinhe <kristinhe@tencent.com>
2026-10-22 16:36:37 +08:00

2.8 KiB

MemHub Localization

MemHub ships Simplified Chinese (zh-CN), English (en), and Spanish (es). Interface language is independent from conversation, memory, extraction, and search language.

Architecture

  • @one-memory/i18n owns supported locales, catalogs, locale resolution, interpolation, plural rules, and formatting helpers.
  • Web owns the active UI preference and reacts immediately without remounting product state.
  • Electron persists the preference before Web starts so startup screens, dialogs, menus, and tray items use the same locale.
  • system is a preference, not a locale. It resolves a supported system language and falls back to English.
  • User-authored text, memory content, raw conversations, paths, source names, model names, endpoints, identifiers, and external error bodies are never translated.

The runtime uses i18next for CLDR plural selection, fallback, and interpolation. Date, number, list, and relative-time formatting use the platform Intl APIs.

Catalog rules

  1. Use stable, domain-qualified keys such as settings.language.title and sdk.memory.delete.confirm.
  2. Keep the same key and placeholders in every locale.
  3. Do not use Chinese or English source text as a new key.
  4. Do not concatenate translated fragments when one message with parameters can express the sentence.
  5. Keep technical identifiers outside translated messages unless they are explicit interpolation parameters.
  6. Use the language's own name in selectors: 简体中文, English, Español.
  7. Do not use national flags to represent languages.

Existing compatibility keys are retained while screens move to semantic keys; new code must not add another source-text key.

Adding a language

  1. Add its BCP 47 locale to SUPPORTED_LOCALES.
  2. Add a complete catalog with placeholder parity.
  3. Add locale resolution and fallback tests.
  4. Add the self-name to the language selector.
  5. Verify Web and Electron-native surfaces.
  6. Test long text with a pseudo-locale or deliberately expanded translations.
  7. For right-to-left languages, set dir and use logical CSS properties.

A locale contribution should primarily change catalog and locale metadata. Large unrelated component or product-behavior changes belong in separate PRs.

Verification

Run focused tests while developing:

bash scripts/run-tests-isolated.sh pnpm \
  --filter @one-memory/i18n exec vitest run
bash scripts/run-tests-isolated.sh pnpm \
  --filter @one-memory/web exec vitest run <affected tests>
bash scripts/run-tests-isolated.sh pnpm \
  --filter @one-memory/desktop exec vitest run <affected tests>

Catalog tests enforce key coverage, placeholder parity, plural behavior, and safe fallback. Component tests must verify that changing locale does not repeat network requests, lose form state, broaden authorization, or modify user data.