Skip to content

fix(ui): Market Pulse 敞口单元格工具提示使用译文而非 {t(...)} 字面量 - #238

Merged
helsome merged 1 commit into
helsome:mainfrom
wxrbyte:codex/fix-pulse-title-i18n
Oct 18, 2026
Merged

helsome merged 1 commit into
helsome:mainfrom
wxrbyte:codex/fix-pulse-title-i18n

Conversation

@wxrbyte

@wxrbyte wxrbyte commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

问题与修复

MarketPulse 的 ImpactRow(packages/ui/src/components/pulse/MarketPulse.tsx:133、:137)把 t() 写进了字符串字面量:

<span className="font-mono text-foreground/64" title="{t('today.watchlistWeightShare')}">
<span className="font-mono text-foreground/64" title="{t('today.portfolioExposure')}">

JSX 属性里的 title="{...}" 是普通字符串,{t('...')} 不会被求值 —— 悬停工具提示逐字显示模板原文,而且不随语言切换变化(t 从未被调用)。这两个键的译文其实早已存在:packages/i18n/src/locales/en-US/today.ts:69-70。

修复:去掉引号,改为 JSX 表达式。

title={t('today.watchlistWeightShare')}
title={t('today.portfolioExposure')}

同文件上方的正确写法随处可见(例如 AnswerBlockFrame.tsx:70、:80 的 title={tip})。

Closes #237

可复现测试报告

环境:Windows 11 / Bun 1.4.2;本地基线 = 上游 main ba5dcdfd31b162f5edb8b908f7f099a560389326(2026-09-24T11:05:17Z),工作树已按 main 字节对齐。

在既有 packages/ui/src/components/pulse/MarketPulse.test.tsx 中新增 1 例(沿用该文件已有的 clientWithPulse(SNAPSHOT) 夹具,快照里两条 personalImpact 分别覆盖「两种敞口都有」与「只有自选敞口」):

阶段 命令 结果
修复前 bun test ./packages/ui/src/components/pulse/MarketPulse.test.tsx 5 pass / 1 fail
修复后 同上 6 pass / 0 fail

修复前的具体不符:新用例的 titles.every((tip) => tip === 'Watchlist weight share' || tip === 'Portfolio exposure') 得到 false —— 实际 title 属性是 {t('today.watchlistWeightShare')} / {t('today.portfolioExposure')} 原文。

硬门禁:

  • bun run typecheck —— core / i18n / shared / ui / electron 五个工作区全部 exit 0。
  • bun test packages/ui --isolate —— 全绿(对齐 main 的本机基线 + 本轮新增用例)。

未运行的测试:未跑 bun test --isolate 全量(本机 6 核 / 8GB 负载下超时抖动明显,且本 PR 只动 packages/ui);apps/electron e2e 未跑,本机沙箱无法 spawn cmd.exe(已知环境限制)。

UI 变化

「What matters to me」区块里两个敞口单元格的悬停工具提示,从 {t('today.watchlistWeightShare')} / {t('today.portfolioExposure')} 变为译文 Watchlist weight share / Portfolio exposure(zh-CN 下显示中文)。单元格文本、布局、样式与 DOM 结构均无变化;无新增依赖;未改动任何公共导出面。

`ImpactRow` 把 `t()` 写进了字符串字面量:
`title="{t('today.watchlistWeightShare')}"`。JSX 不会对属性里的 `{}` 求值,
于是工具提示逐字显示模板原文,而不是译文 —— 且不随语言切换变化。

去掉引号改为 JSX 表达式,复用既有的 `today.*` 资源。

在既有 `MarketPulse.test.tsx` 中新增 1 例断言 `title` 属性:
修复前 5 pass / 1 fail → 修复后 6 pass / 0 fail。

@helsome helsome left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

本轮独立源码审查及精确 HEAD focused 11/0 通过。最新main累计组合完整测试1959 pass / 7 skip / 0 fail,全workspace typecheck、i18n通过,secret扫描零命中。仅按本PR声明范围验收,不把离线回归当真实模型/生产API验收。

@helsome
helsome merged commit d9babea into helsome:main Oct 18, 2026
5 checks passed
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.

fix(ui): Market Pulse 敞口单元格工具提示显示 {t(...)} 字面量而非译文

2 participants