Skip to content

feat(i18n): show the page in English and Simplified Chinese - #184

Merged
AliceSaikawa merged 6 commits into
mainfrom
feat/issue-78-en-zh
Oct 22, 2026
Merged

AliceSaikawa merged 6 commits into
mainfrom
feat/issue-78-en-zh

Conversation

@AliceSaikawa

@AliceSaikawa AliceSaikawa commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Why

The last step of Issue #78. With every dictionary translated in #175–#183, the page can follow DSH's language setting (or the browser when nothing is set) in Japanese, English and Simplified Chinese. This branch stacks on those PRs by merging them: until they land, the diff includes them. Review only the commits that are not merges: test(i18n): fail when a Japanese UI string lives outside a dictionary, feat(i18n): show the page in English and Simplified Chinese, and the four review fixes after the latest merges. I will rebase onto main once they are merged.

Scope

  • DISPLAY_LOCALES is ['ja', 'en', 'zh'] (web/src/i18n/locale.ts). Outside a page, localeStore starts in Japanese (web/src/i18n/current.ts).
  • Settings → General → Language offers 日本語 (generalRows in general.ts); languageDescription is rewritten in all three languages.
  • Tests: tests/11-i18n-literals.test.ts fails on a Japanese string outside messages.ts (mock data and logs excepted); tests/11-i18n.test.ts fails on kana in English or Chinese, or Han in English. e2e/i18n.spec.ts replaces i18n-foundation.spec.ts; settings-general G13–G15 now expect the page to switch.
  • The first paint waits at most FIRST_LOCALE_WAIT_MS (1 s) for the first locale.preference read: connectLocalePreference returns a disposer with ready, and main.tsx waits through waitAtMost (web/src/i18n/dsh.ts).
  • ModelsPanel.tsx shows catalog failures through the composer's errorText (M3E's own LocalizedError texts and Host failures only) instead of a kana and kanji check.
  • Docs: docs/design/11-i18n.md, 08-settings.md, docs/ui-spec.md, docs/i18n/glossary.md (common rows and links to docs/i18n/terms/*), the three READMEs, CHANGELOG.md.

Tradeoffs

  • 日本語 is offered although the standard screen cannot show it; choosing it makes the standard screen fall back to the browser language. Without it, a Japanese reader with an English browser had no way to get a Japanese M3E.
  • Unit tests in Node use Japanese whatever the machine's language, so CI (en-US) and local runs agree; tests that need another language pass it explicitly.
  • Texts already kept in state (a draft's send error, labels the settings store read) stay in the old language until they are made again.

Blast radius

Every screen changes for English and Chinese readers, and for anyone whose DSH language is English or Chinese. Japanese readers see no change: the whole mock e2e suite runs in ja-JP.

Verification

  • pnpm typecheck, tsc -p tsconfig.e2e.json, pnpm test (1,515 tests, 1,513 pass, 2 existing skips; same result with LANG=en_US.UTF-8, zh_CN.UTF-8 and C), pnpm build, pnpm check:pack, git diff --check pass.
  • Mock e2e: all 425 tests pass, including e2e/i18n.spec.ts (switching via DSH without reload; en-US, zh-CN, zh-SG, zh-TW, fr-FR browsers; start-up failure text) and settings-general G13–G16.
  • 27 mock screens opened in en-US and zh-CN before the review fixes: the only Japanese left is mock data (titles, fake providers and plugins, Host texts). Not reopened after the fixes.
  • Not checked: a real DSH and a real phone.

Refs #78

Copy link
Copy Markdown
Owner Author

独立レビュー(自動)の結果です。

判定:直してからマージ(#175〜#183 のマージ後に rebase してから)

指摘(優先度順)

  1. マージ順:この PR は feat(host): localize the sign-in page and the stock settings row #175〜feat(i18n): add en and zh to shared texts and the conversation screen #183 のコミットをすべて含んでいます
  2. 最初の描画が DSH の言語設定を無視する(web/src/main.tsx:23、:34-35)
    • startLocale() はブラウザの言語で始まり、connectDshLocale(ctx) の読み込み(非同期)を待たずに createRoot(...).render(...) します。DSH で別の言語を選んでいると、最初は端末の言語で描かれ、読み込み後に切り替わります。
    • 直し方:最初の locale.preference の読み込みを短い待ち時間つきで待ってから描画する、または前回の preference を保存して startLocale で使ってください。
  3. 名前のない添付ファイルの表示名が日本語に固定(web/src/features/chat/model.ts:115、web/src/features/chat/messages.ts:317)
    • attachmentText = messagesOf(attachmentMessages, SOURCE_LOCALE) のため、英語・中国語の画面でも「添付ファイル」と出ます(feat(i18n): move chat texts into dictionaries with English and Chinese #181 と同じ問題。この PR で全画面が英語・中国語になるので表に出ます)。
    • 直し方:表示時に currentLocale() の辞書で引くか、描画側で defaultFileName に置き換えてください。
  4. ModelsPanel のかな・漢字判定が残っている(web/src/features/settings/ModelsPanel.tsx:35)
    • /[\u3040-\u30ff\u3400-\u9fff]/.test(cause.message) なら Host の文をそのまま出すため、英語画面で日本語・中国語の文が出たり、中国語画面に日本語(かな)が出たりします。
    • 直し方:設計書の「保存拒否の理由」の規則(docs/design/11-i18n.md の displayableRejection:日本語は日本語の文だけ、中国語はかなを含まない漢字だけ、英語は常に固定文言)と同じ判定に置き換えるか、displayableRejection を共有してください。
  5. 言語の説明が実際の動きと合わない(web/src/features/settings/messages.ts:149 日本語、:171 英語、:193 中国語 languageDescription)
    • 説明は「端末の言語が日本語・English・中文のどれでもなければ English」ですが、requestedLocale(web/src/i18n/locale.ts:66)は navigator.languages を順に見て、最初に対応している言語を使います(例:fr, ja なら日本語)。繁体字(zh-TW など)は English になる点も書かれていません。
    • 直し方:コードの動きどおりに三言語の説明を直してください(「端末の言語の優先順で、最初に対応している言語。なければ English」)。
  6. タイトルは 59 字で OK(72 字以内)。

確認済み

  • typecheck・test(失敗 0)は通っています。

tests/11-i18n-literals.test.ts reads every web/src source file with the TypeScript parser and fails on a Japanese string, template or JSX text outside messages.ts, mock data and console logs. Such a string would stay Japanese for English and Chinese readers.
The page now follows DSH's language setting, or the browser language when nothing is set, and is shown in Japanese, English or Simplified Chinese. Other languages, Traditional Chinese included, are shown in English, and a change applies without a reload. The Language row in Settings → General also offers 日本語.
…tion store

The shell PR returned interactions-store.ts to fixed Japanese, because docs/design/11-i18n.md keeps those reasons out of the dictionaries: they go back to the DSH requester and are not shown. The literals test lists them as allowed with that reason.
The page used to paint in the browser's language and switch once locale.preference arrived. connectLocalePreference now returns a disposer with a ready promise for the first read, and main.tsx waits for it at most FIRST_LOCALE_WAIT_MS before rendering, so a slow or failed read never holds the page.
ModelsPanel showed any error message that contained kana or kanji, so a Japanese Host text could reach the English page and kana could reach the Chinese page. It now uses errorText from the composer, which shows LocalizedError messages and Host failures through remoteErrorMessage, and the per-provider failure rows show catalogFailed instead of the Host text.
With "Match device language" the page uses the first of Japanese, English or Simplified Chinese in the device's language order, and English when none is there. The language row description now says so in all three languages instead of saying that any other first language gives English.
@AliceSaikawa
AliceSaikawa merged commit 6b5ad86 into main Oct 22, 2026
6 checks passed
@AliceSaikawa
AliceSaikawa deleted the feat/issue-78-en-zh branch October 22, 2026 13:14
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