feat: Add i18n (internationalization) support for multi-language UI#73
feat: Add i18n (internationalization) support for multi-language UI#73ryouka0731 wants to merge 8 commits intostandardagents:mainfrom
Conversation
- Add i18n infrastructure with locale management (src/i18n/) - Create English (en) and Japanese (ja) translation files - Add language setting to DmuxSettings type - Add language selector to settings UI - Apply language setting in DmuxApp on startup - Replace hardcoded commit option labels with i18n translations This allows users to switch between English and Japanese from settings.
- Fix ESM compatibility: use import.meta.url instead of __dirname - Make translation loading dynamic (scan locales directory) - Add reactive settings updates with useMemo - Add getLocalizedSettingDefinitions() for translated UI labels - Update PopupManager to use localized setting definitions
|
This is a great idea, but causes some significant issues:
|
# Conflicts: # src/DmuxApp.tsx # src/services/PopupManager.ts # src/utils/settingsManager.ts
… side effects Replaces fs/JSON-at-runtime loading with statically imported TypeScript locale modules. This addresses two of the three review items on PR standardagents#73: - Translation files are now part of the TypeScript build output, so release builds no longer fall back to raw keys (locales were missing from package.json `files` previously). - SettingsManager and other non-UI consumers no longer trigger fs reads at module import time, fixing the test-isolation regression seen with mocked fs modules. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces src/i18n/locales/en.json with en.ts so translations ship as part of dist/i18n/locales after tsc — the JSON file was not included in the published package's `files` allowlist. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces src/i18n/locales/ja.json with ja.ts so translations ship as part of dist/i18n/locales after tsc. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Covers the public i18n contract: default locale, locale switching, unknown-locale handling, nested key lookups, fallback to English for missing keys, key-as-default behavior for unknown keys, parameter interpolation, getAvailableLocales immutability, and translation parity for a representative key set across en/ja. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ones
The previous tests for English fallback and {param} interpolation only
exercised hand-written regex copies of the implementation, not the
public t() API. They also covered just 10 representative keys.
Replaces them with:
- vi.doMock-driven tests that load i18n with controlled asymmetric
locales to truly drive the en-fallback path through t().
- Interpolation tests that resolve placeholders through t() with a
bundled placeholder string, including numeric coercion, missing
values left as-is, and the no-interpolation-on-unknown-keys contract.
- A deep en/ja key-tree parity check (every leaf path must exist on
both sides) and a full round-trip that asserts every bundled key
resolves to a non-key string in both locales.
- A source-level guard ensuring src/i18n/index.ts never reintroduces
fs / readFileSync / readdirSync imports — the regression vector
flagged by PR standardagents#73 review item 3.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Thanks for the thorough review! All three items are addressed; the branch is now merged with 1. Locale JSONs missing from the published buildReplaced Verified end-to-end: Commits: 2. Settings non-reactive after saveIn the meantime Commit: 3. fs side effects on every SettingsManager consumer
To keep this property over time, Commit: TestsAdded
|
Summary
Adds internationalization (i18n) support to dmux, allowing users to switch between English and Japanese from settings.
Closes #72
Changes
Core i18n Infrastructure
src/i18n/index.tswith I18nManager class for locale managementsrc/i18n/locales/en.json- English translationssrc/i18n/locales/ja.json- Japanese translationsSettings Integration
language?: 'en' | 'ja'field toDmuxSettingstypegetLocalizedSettingDefinitions()function for translated UI labelsUI Integration
Technical Improvements
import.meta.urlinstead of__dirnamet('key', { param: value })How to Use
Future Improvements