i18n-page-title
按用户指定目录扫描并翻译页面标题(navigationBarTitleText、SpPage title、setNavigationBarTitle)。用户说「翻译页面 title」「目录下 title 没翻译」「i18n page title」时触发。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
按用户指定目录扫描并翻译页面标题(navigationBarTitleText、SpPage title、setNavigationBarTitle)。用户说「翻译页面 title」「目录下 title 没翻译」「i18n page title」时触发。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
按 GitLab TBID 强制校验规范提交 Git 变更并在对话中总结。提交信息必须以 [TBID:项目ID-任务编号] 开头。用户说「提交」「提交并总结」「帮我 commit」时使用;不写 .cursor/commit-summary 文件。
按计划文件顺序逐文件完成 i18n(哈希键 + @/i18n 的 $t/ti,禁止页面使用 globalThis.$t),维护 subpages/i18n/locales 三语,并在对应 plan 中更新进度与统计。用户说「按计划做 i18n」「继续翻译 plans」时触发。
Summarize current code changes and optionally commit. Use when the user asks to summarize what changed, record changes, commit with a message, or "总结这次改了什么并提交"/"帮我 commit".
Use when analyzing a frontend codebase, onboarding into an existing project, or documenting stack, structure, configs, and coding conventions into .f2e-ai/handbook/.
Use when a requirement-id is ready for delivery and the next step is to summarize Git changes, write change-summary.md, commit, push, and prepare a PR.
Use when a requirement-id already has test.spec.ts and the next step is to run Playwright and persist the results in test-result.md.
| name | i18n-page-title |
| description | 按用户指定目录扫描并翻译页面标题(navigationBarTitleText、SpPage title、setNavigationBarTitle)。用户说「翻译页面 title」「目录下 title 没翻译」「i18n page title」时触发。 |
Taro 页面标题常出现在 3 处,只改一处会导致切换语言后仍显示中文:
| 位置 | 典型写法 | 处理方式 |
|---|---|---|
*.config.js | navigationBarTitleText: '中文' | 改为 ''(与项目多数页面一致) |
*.js / *.jsx | setNavigationBarTitle($t('key')) | 保留;无则按模板补齐 |
SpPage 等自定义导航 | title='中文' | 改为 title={$t('key')},key 与上一行一致 |
navigationStyle: 'custom' 时,用户看到的是 SpPage title,不是 config 里的 navigationBarTitleText。
用户给出 扫描目录(相对仓库根),例如:
src/subpages/storesrc/subpages/item可选:只处理某个子路径、或「仅扫描不修改」。
在仓库根执行:
python3 .cursor/skills/i18n-page-title/scripts/scan_page_titles.py --dir "src/subpages/store"
脚本输出三类问题:
*.config.js 里 navigationBarTitleText 含中文SpPage / 同类组件 title='中文'$t('xxx.yyy') 但 zhcn.json 无该键(顺带列出 en/ar 缺失)也可手动:
rg -n "navigationBarTitleText:\s*'[^']*[\u4e00-\u9fff]" <目录> --glob '*.config.js'
rg -n "title=['\"][^'\"]*[\u4e00-\u9fff]" <目录> --glob '*.{js,jsx}'
rg -n "setNavigationBarTitle\([^$]" <目录>
键格式:{file_hash}.{text_hash}(与 i18n-translate 一致)
file_hash = md5(相对路径) 前 8 位,路径以 src/ 开头text_hash = md5(中文标题) 前 6 位python3 .cursor/skills/i18n-page-title/scripts/gen_i18n_key.py \
--path "src/subpages/store/list.js" --text "店铺列表"
主 key 来源:优先用 页面 *.js(如 list.js),setNavigationBarTitle 与 SpPage title 共用同一 key。
若代码里已存在 $t('…') 且三语 locale 已有该键,直接复用,不要为同一文案再生成新键。
历史代码可能用 *.config.js 路径生成的 key(如 5cfe28e8.a4d703 来自 list.config.js):只要 locale 齐全,可继续用,不必强行改成 list.js 的 hash。
*.config.js
export default {
navigationBarTitleText: '',
// ...
}
*.js — 动态标题(无则添加)
import { useTranslation, $t, i18n } from '@/i18n'
import { useNavigation } from '@/hooks'
function Page() {
useTranslation()
const { setNavigationBarTitle } = useNavigation()
useEffect(() => {
const syncTitle = () => setNavigationBarTitle($t('xxxxxxxx.yyyyyy'))
syncTitle()
i18n.on('languageChanged', syncTitle)
return () => i18n.off('languageChanged', syncTitle)
}, [setNavigationBarTitle])
return (
<SpPage title={$t('xxxxxxxx.yyyyyy')}>
useTranslation(),保证语言切换后 $t 更新。SpPage 的 title 与 setNavigationBarTitle 使用 相同 key。不要在 *.config.js 写 $t()(编译期不支持)。
写入(键已存在则只校对译文):
src/subpages/i18n/locales/zhcn.json — 中文原文src/subpages/i18n/locales/en.jsonsrc/subpages/i18n/locales/ar.jsonen / ar 可先在同文件或全库 rg 搜相同中文是否已有译法,再落键。
对目录内已改页面:
navigationBarTitleText: '中文'title='中文' / title="中文"(SpPage 等)setNavigationBarTitle($t(...)) + languageChanged 监听SpPage title={$t(...)} 与导航栏 key 一致i18n-translate 的关系i18n-translate:整文件 UI 文案,按计划 plans/*.md 执行。目录内除 title 外还有大量中文时,title 用本技能修完后,其余仍走 i18n-translate。
subpages/store/list问题:list.js 已 setNavigationBarTitle($t('5cfe28e8.a4d703')),但 SpPage title='店铺列表' 未译。
修复:
list.config.js → navigationBarTitleText: ''list.js → title={$t('5cfe28e8.a4d703')}5cfe28e8.a4d703 在三语 locale 中存在完成后简要列出: