ForgeFlow-ERP/docs/superpowers/plans/2026-06-01-dictionary-localization.md
2026-06-12 16:00:56 +08:00

55 lines
2.4 KiB
Markdown

# Dictionary Localization Implementation Plan
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
**Goal:** Convert visible English enum/dictionary values in ERP business screens to Chinese without changing stored enum codes.
**Architecture:** Centralize translations in `frontend/src/utils/dictionaries.js`, then update high-risk screens to use formatter helpers instead of raw enum output. Add a static regression script to prevent common untranslated enum leaks from returning.
**Tech Stack:** Vue 3 SFC, frontend utility modules, Node static checks, Vite build.
---
### Task 1: Expand Frontend Dictionary Utilities
**Files:**
- Modify: `frontend/src/utils/dictionaries.js`
- [ ] Add formatter maps for missing statuses, inventory transaction types, source document types, warehouse types, item types, purchase source types, maintenance types, miniapp roles, and stocktake row statuses.
- [ ] Make dictionary lookup normalize string keys to uppercase.
- [ ] Add Chinese fallback for unknown enum-like values so raw English enum codes are not displayed.
### Task 2: Replace Direct Enum Rendering In High-Risk Views
**Files:**
- Modify: `frontend/src/views/InventoryLedgerView.vue`
- Modify: `frontend/src/views/EquipmentManagementView.vue`
- Modify: `frontend/src/views/EmployeeManagementView.vue`
- Modify: `frontend/src/components/StocktakeDialog.vue`
- Modify: `frontend/src/views/PurchaseOrderView.vue`
- [ ] Inventory: translate stock lot quality/source/item displays and ledger type/source values.
- [ ] Equipment: translate maintenance type values.
- [ ] Employee: translate miniapp role codes even if backend returns raw role values.
- [ ] Stocktake: translate row status and keep existing diff/status translation.
- [ ] Purchase order: translate purchase source type in search and sort-facing display helpers.
### Task 3: Add Static Regression Check
**Files:**
- Create: `frontend/scripts/test-dictionary-localization.mjs`
- [ ] Verify dictionary maps include common English codes that previously leaked.
- [ ] Verify high-risk views call the new formatter helpers.
- [ ] Verify dictionary fallback does not return raw enum-like English.
### Task 4: Verify
**Files:**
- No source edits expected.
- [ ] Run `node scripts/test-dictionary-localization.mjs`.
- [ ] Run existing inventory static scripts.
- [ ] Run `npm run build`.