i18n-hardcoded-strings-audit.md 8.2 KB

前端页面硬编码文案梳理(i18n 未覆盖)

针对以下路由对应页面的硬编码中文/英文梳理,包括按钮、message、placeholder、aria-label、alt 等。

路由 页面组件
/login-register LoginRegisterPage
/email-login LoginPage
/login-verification-input LoginVerificationInputPage
/chatbot ChatBotPage
/profile ProfilePage
/welcome WelcomePage
/naming GreetingPage
/lumi-naming LumiNamingPage
/first-login-reward FirstLoginRewardPage
/share-success ShareSuccessPage

1. /login-register(LoginRegisterPage.tsx)

位置 类型 当前文案 说明
约 L89 页面标题 Hello, 写死英文,应使用 t('login:title')(login.json 已有 title)

其余按钮、协议文案、message 均已使用 t('login')。


2. /email-login(LoginPage.tsx)

位置 类型 当前文案 说明
L49-50 区号选项 label: '中国', label: '英国' 写死中文,需加入 i18n(如 common 或 login)
L204 aria-label "Back" 建议 t('common:button.back') 或新增 key
L208 alt "Back" 同上
L219 alt "cheer animation" 可做 a11y key
L289 alt "area flag" 可做 a11y key
L334 alt "arrow" 可做 a11y key

message、placeholder、按钮文案均已用 t()。


3. /login-verification-input(LoginVerificationInputPage.tsx)

位置 类型 当前文案 说明
L321 aria-label "Back" 建议 i18n
L327 alt "Back" 同上
L335 alt "cheer animation" 可做 a11y key

其余 message、按钮、弹窗文案均已用 verification/login/error 的 t()。


4. /chatbot(ChatBotPage.tsx)

位置 类型 当前文案 说明
L2965 alt "Trees" 写死英文,建议 i18n(如 common 或新增 chatbot)
L3355 alt "Yp" 品牌/产品名可保留或统一 key
L3440 aria-label "Menu" 建议 i18n
L3444 alt "Menu" 同上
L3580 alt "Cancel" 建议 i18n
L3584 alt "Cancel Tooltip" 建议 i18n
L3626 alt "Record" 建议 i18n
L3633 alt "Tap to Chat" 建议 i18n
L3708 alt "Send" 建议 i18n
L3712 alt "Send Tooltip" 建议 i18n

antMessage 已统一使用 tCommon()。建议:为 chatbot 页新增 chatbot namespace(或复用 common)统一上述 a11y/alt 文案。


5. /profile(ProfilePage.tsx)

位置 类型 当前文案 说明
L354 加载状态 加载中... 写死中文,应使用 tCommon('message.loading') 或 common 中已有 loading key
L399 用户名占位 username \|\| 'User' 英文 "User" 写死,建议 i18n 占位名(如 profile.userDefault)
L783, L916 aria-label "清除" 写死中文,建议 t('common:button.clear') 或 profile 中 clear key
L793, L926 alt "清除" 同上

其余标题、按钮、反馈 placeholder 等已用 t()。


6. /welcome(WelcomePage.tsx)

当前未使用 useTranslation,整页需接入 i18n。

位置 类型 当前文案 说明
L43 message.error '用户未注册,请先注册' 写死中文,建议 error 或 welcome namespace
L73 message.warning '响应超时,请重试' 写死中文,建议 common/error
L529 aria-label "Start your journey" 写死英文,建议 welcome 或 common
L534 alt "Start your journey" 同上
L616 加载文案 视频加载中... 写死中文,建议 welcome.videoLoading 等
L634 兜底提示 您的浏览器不支持HTML5视频,请升级浏览器。 写死中文,建议 welcome.unsupportedVideo 等

建议:引入 useTranslation('welcome'),并在 welcome.json 中增加:userNotRegistered、responseTimeoutRetry、startJourney、videoLoading、unsupportedVideo 等;与 error/common 重复的可复用已有 key。


7. /naming(GreetingPage.tsx)

位置 类型 当前文案 说明
L78 message.warning '响应超时,请重试' 写死中文,建议 tCommon 或 error
L225 aria-label "返回" 写死中文,建议 tCommon('button.back')
L241 按钮 Replay intro 写死英文,建议 welcome/naming 的 replayIntro
L264 标题 What is your name ? 写死英文,建议 naming 的 whatIsYourName
L277 副标题 我应该怎么称呼你呢 ? 写死中文,建议 naming 的 howShouldICallYou
L339 aria-label "清除" 写死中文,建议 t('common') clear
L346 alt "清除" 同上

下一步按钮已用 t('nextStep')。


8. /lumi-naming(LumiNamingPage.tsx)

位置 类型 当前文案 说明
L115 aria-label "返回" 写死中文,建议 tCommon('button.back')
L155 标题 What is my name ? 写死英文,建议 naming/lumi 的 whatIsMyName
L166 副标题 给我一个地球人的名字吧 ! 写死中文,建议 naming 的 giveMeAName
L202 placeholder DEFAULT_LUMI_NAME('Lumi') 产品名可保留,若需多语言可做 key
L222 aria-label "清除" 写死中文,建议 t clear
L226 alt "清除" 同上

下一步按钮已用 t()。


9. /first-login-reward(FirstLoginRewardPage.tsx)

位置 类型 当前文案 说明
L273 aria-label "Back" 建议 i18n
L279 alt "Back" 同上
L341 标题 Congratulation! 写死英文且拼写建议为 Congratulations,建议 common.firstLoginCongrats 等
L428 aria-label "Previous image" 建议 i18n
L461 aria-label "Close share modal" 建议 i18n
L453 alt "Previous" 建议 i18n
L468 alt "Close" 建议 i18n
L443 alt "Next" 建议 i18n
L451 alt "Share preview" 等 建议 i18n

描述、分享按钮、领取按钮等已用 tCommon。


10. /share-success(ShareSuccessPage.tsx)

位置 类型 当前文案 说明
L131 标题 Happy New Year! 写死英文,建议 common.shareSuccessTitle 或 welcome 中 key

描述、继续聊天按钮已用 tCommon。


建议的 i18n 改动优先级

  1. 高(用户可见、单语明显)

    • WelcomePage:整页接入 i18n(错误提示、加载文案、视频兜底文案、Start your journey)。
    • GreetingPage / LumiNamingPage:标题、副标题、Replay intro、返回/清除。
    • ProfilePage:加载中、User 占位、清除。
    • LoginRegisterPage:Hello → t('login:title')。
    • LoginPage:区号选项「中国」「英国」。
    • FirstLoginRewardPage:Congratulation(s)、Back/Close/Previous/Next 等。
    • ShareSuccessPage:Happy New Year。
  2. 中(无障碍与一致性)

    • 各页统一 Back/清除/Menu/Cancel/Send/Record/Tap to Chat 等 aria-label 与 alt,放入 common 或各 namespace。
  3. 低(品牌/产品名)

    • 如 Lumi、Yp 等可保持或统一 key 便于以后多语言。

现有 i18n 命名空间与可复用 key

  • common:button.back、button.cancel、message.loading、feedbackPlaceholder、share、continueChat、claimGift 等。
  • login:title、continueEmail、continuePhone、nextStep、clear、inputEmail、inputPhone 等。
  • verification:sentTo、resendAfter、startJourney、earlyCommunityDesc 等。
  • profile:head、background、feedbackAndHelp、userAgreement、privacyPolicy、placeholderUsername、placeholderLumiName 等。
  • error:错误码对应文案。
  • welcome:目前仅部分 key,需扩展(见上)。

建议:naming 相关(What is your name、我应该怎么称呼你呢、What is my name、给我一个地球人的名字吧、Replay intro)可放入 welcome 或新增 naming namespace(config 中已有 'naming',可补 zh/en 的 naming.json)。