11 KiB
Implementation Tasks — i18n-frontend-ui-strings
Approved requirements and design. Tasks ordered Foundation → Core → Integration → Validation per the project's tasks-generation rule.
-
1. Foundation: locale-file additions and audit tooling
-
1.1 Add the new
process.*,step3.*,step4.*,step5.*keys tolocales/en.json(English-only values)- Add a new top-level
processnamespace covering every literal flagged forProcess.vue(header, status badges, progress hints, error messages, fallback names, project-info modal labels, environment-setup-coming-soon alert). - Add
step3.startFailedif not already present (verify against current file). - Add
step4.selectionReasonandstep4.awaitingStart. - Add
step5.chatRolePrompter,step5.chatRoleYou,step5.chatHistoryPrefix({history},{message}ICU params). - Strings carry idiomatic English wording only — no Chinese characters in
en.json; the design's bilingual sketch is only a reviewer aid. - Observable completion:
rg '[一-鿿]' locales/en.jsonreturns no hits in any newly added key (existing meta entries excluded). - Requirements: 1.5, 3.1, 3.3, 3.4
- Add a new top-level
-
1.2 (P) Mirror the new keys to
locales/zh.jsonwith the original Chinese wording- For each key added in 1.1, add an entry in
zh.jsoncarrying the exact Chinese string removed from the source files (no paraphrasing). - Preserve existing namespace order; add new entries at the end of each namespace block to minimise diff noise.
- Observable completion:
jq -S 'paths(scalars) | join(".")' locales/en.json | sort -uand the same forzh.jsonproduce identical output. - Requirements: 3.1, 3.2, 3.4, 3.5
- Boundary: locales/zh.json
- Depends: 1.1
- For each key added in 1.1, add an entry in
-
1.3 (P) Author the audit verifier
frontend/scripts/audit-i18n-strings.sh- Greps a CJK code-point range over the five files in scope only (no project-wide scan).
- Filters out an explicit allowlist: the
REPORT_MARKERSliteral block inStep4Report.vue, the bilingual log-severity helper, and any line with a trailing// i18n-allow:<reason>comment. - Adds a key-parity check:
jqover both locale files; reports keys missing from either side. - Exits 0 on success, 1 with a human-readable list otherwise.
- Observable completion: running the script against the current branch (before the source-file changes) prints the expected hit list (sanity check); after the source-file changes it exits 0.
- Requirements: 6.1, 6.2, 6.3, 6.4
- Boundary: frontend/scripts/
-
2. Core: externalize
Process.vue -
2.1 Wire
vue-i18nintoProcess.vue- Add
import { useI18n } from 'vue-i18n'andconst { t } = useI18n()to the<script setup>block. - Run a smoke check (
npm run dev, open the page) to confirm the import does not regress the existing render. - Observable completion: file compiles, dev server reloads, the page still renders identically (no Chinese strings replaced yet).
- Requirements: 1.1, 2.6
- Boundary: Process.vue
- Add
-
2.2 Replace the graph-panel and header literals in
Process.vue- Substitute lines 26, 30, 32, 36, 39, 53 (header title, node/edge counts, refresh-button title, fullscreen toggle title, real-time-updating hint).
- Reuse
graph.*keys where they already exist; introduceprocess.graphPanelTitle,process.nodes,process.edges,process.refreshGraph,process.exitFullscreen,process.enterFullscreen,process.realtimeUpdatingonly as needed. - Observable completion: switch to
enlocale, reload, confirm the graph panel header reads in English; switch tozh, confirm the original Chinese is unchanged. - Requirements: 1.1, 1.2, 1.3
- Boundary: Process.vue
-
2.3 Replace the build-flow section literals in
Process.vue- Substitute the ontology section (lines 174, 192, 193, 203, 204, 228, 237, 247, 249, 255, 264, 277, 298) and the graph-build section (lines 308, 318, 320, 326, 346, 350, 354, 366, 367, 378).
- Substitute the project-info modal labels (lines 388, 392, 396, 400, 404).
- Substitute the environment-setup-coming-soon alert at line 482.
- Observable completion: full walk of the build-flow on
enlocale shows English throughout; onzhmatches today's wording. - Requirements: 1.1, 1.2, 1.3
- Boundary: Process.vue
-
2.4 Replace the script-side error/status literals and fallback names in
Process.vue- Substitute the build-status computed (lines 452–458), the step-status computed (lines 536, 541, 543), the no-files error (line 563), and every error-assignment fallback through the watcher (lines 571, 598, 602, 634, 638, 657, 667, 673, 681, 686, 763, 778, 797).
- Substitute the D3 fallback labels (lines 872, 884, 900, 901):
t('process.waitingGraphData'),t('process.fallbackNodeName'),t('common.unknown'). - Observable completion: trigger an error path (e.g., upload no files) on
enlocale; the resulting error message renders in English. - Requirements: 1.1, 1.2, 1.3, 1.4
- Boundary: Process.vue
-
3. Core: externalize step components
-
3.1 (P) Replace the
'启动失败'fallback inStep3Simulation.vue- Substitute
startError.value = res.error || '启动失败'(line 423) witht('step3.startFailed'). - Confirm
step3.startFailedis present in both locale files (added in 1.1/1.2 if missing). - Observable completion: trigger a backend simulation-start failure on
enlocale; the inline error message reads in English. - Requirements: 2.1, 2.4, 2.6
- Boundary: Step3Simulation.vue
- Depends: 1.1, 1.2
- Substitute
-
3.2 (P) Replace user-visible Chinese literals and centralize regex markers in
Step4Report.vue- Add a frozen
REPORT_MARKERSconstants block at the top of<script setup>, with one entry per backend-coupled marker (28 regex entries + anoReply.is(value)predicate + alogSeverity.{isError,isWarning}(line)helper). Each entry carries an inline comment naming the canonical backend source line inzep_tools.py(or other emitter). - Refactor every parser call site to reference the block:
text.match(REPORT_MARKERS.analysisQuery.regex),if (REPORT_MARKERS.noReply.is(interview.redditAnswer)) …, etc. Touch every flagged line: 555, 557, 561, 565, 566, 567, 573, 580, 590, 597, 598, 609, 644, 652, 663, 673, 702, 706, 714, 816, 844, 845, 871, 893, 915, 923, 930, 943, 850, 854, 1325, 2005, 2006. - Substitute the user-visible literals: line 1464 (
h('div', …, '选择理由')→t('step4.selectionReason')), line 1774 ('等待开始'→t('step4.awaitingStart')). - Mark the
REPORT_MARKERSblock with a leading// i18n-allow: backend-coupled markers; sync with i18n-report-agent-prompts speccomment so the audit script accepts the literals inside. - Observable completion: open a finished project's report on
enlocale; key facts, core entities, relation chains, sub-queries, both interview platforms, and search results render with parity tomain. The "selection reason" header and the "awaiting start" placeholder render in English. - Requirements: 2.2, 2.4, 2.6, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 5.10, 5.11
- Boundary: Step4Report.vue
- Depends: 1.1, 1.2
- Add a frozen
-
3.3 (P) Localize the chat-history templating in
Step5Interaction.vue- Substitute lines 721 and 723. The
historyContextmap becomest('step5.chatRolePrompter')/t('step5.chatRoleYou'). The prompt template usest('step5.chatHistoryPrefix', { history: historyContext, message }). - Confirm the
zh.jsonentries are byte-identical to the original Chinese phrasing so the production Chinese path is unchanged. - Observable completion: on
enlocale, send a question and a follow-up; the second LLM response references the chat history coherently. Onzhlocale, the LLM behaviour is unchanged frommain(smoke test). - Requirements: 2.3, 2.4, 2.6
- Boundary: Step5Interaction.vue
- Depends: 1.1, 1.2
- Substitute lines 721 and 723. The
-
3.4 (P) Refactor the stage watcher in
Step2EnvSetup.vueto useSTAGE_PHASE_MAP- Add a
const STAGE_PHASE_MAP = Object.freeze({ '生成Agent人设': 1, 'generating_profiles': 1, '生成模拟配置': 2, 'generating_config': 2, '准备模拟脚本': 2, 'copying_scripts': 2 })near other module-level constants. - Rewrite the
watch(currentStage, …)body sophase.value = STAGE_PHASE_MAP[newStage] ?? phase.value. Preserve the existing side-effect: when transitioning into phase 2, calladdLog(t('log.startGeneratingConfig'))and start config polling. - Mark the map with
// i18n-allow: backend stage tokens; multi-language toleranceso the audit accepts the embedded Chinese. - Observable completion: simulating each backend stage emission (e.g. via dev-tools console setting
currentStage.value = '生成Agent人设') drivesphase.valueto the expected value; same for the snake_case variant. A new English emission (e.g.'generating profiles') added as a one-line map row works without other edits. - Requirements: 2.5, 2.6, 4.1, 4.2, 4.3, 4.4
- Boundary: Step2EnvSetup.vue
- Add a
-
4. Integration and validation
-
4.1 Run the audit verifier and resolve any remaining hits
- Execute
bash frontend/scripts/audit-i18n-strings.sh. - For each hit, either (a) substitute the literal with a
t()call (and add the new key to both locale files), or (b) annotate the line with// i18n-allow:<reason>if the literal is deliberate. - Re-run until the script exits 0.
- Observable completion: the script exits 0 with no stdout. The
git diffagainstmainshows no further user-visible Chinese in the five files outside the allowlisted blocks. - Requirements: 1.2, 2.4, 6.1, 6.2, 6.3, 6.4
- Depends: 2.1, 2.2, 2.3, 2.4, 3.1, 3.2, 3.3, 3.4
- Execute
-
4.2 Manual end-to-end smoke test on both locales (deferred — requires running backend + browser; flagged in PR description for human reviewer)
- On
enlocale: start a fresh project (file upload → ontology → graph build → env setup → simulation → report → interaction). Verify no unexpected Chinese in the rendered DOM (excluding backend-emitted content currently in Chinese, which is out of scope per the spec boundary). - On
zhlocale: same flow. Verify visual parity withmainfor every screen. - On
enlocale: walk the chat flow in Step5 with one question and a follow-up; confirm the LLM response uses the prior turn coherently (validates the Step5 chat-history change). - On
enlocale: open a previously generated report; confirm key facts, core entities, relation chains, sub-queries, both Twitter and Reddit interview answers, and search-result panes render with parity tomain. - Observable completion: a short note in the PR body listing the two locales tested, the routes walked, and any anomalies found (expected: none).
- Requirements: 1.2, 1.3, 2.4, 5.10
- Depends: 4.1
- On
-
4.3 Locale-parity sanity check
- Run
wc -l locales/en.json locales/zh.json; line counts equal. - Run the parity diff embedded in
audit-i18n-strings.sh; no missing keys reported. - Observable completion: both checks pass; the PR description quotes the verifier output (zero hits + parity OK).
- Requirements: 3.1, 3.5, 6.1
- Depends: 4.1
- Run