xiaohongshu
xiaohongshu
Full skill instructions
i18n 硬編碼檢查和批量處理工具。
| 工具 | 用途 | 適用場景 |
|---|---|---|
| style-guardian | 快速檢查 UI 層的樣式和 i18n | CI/CD、pre-commit hook、日常開發 |
| i18n-checker | 深入批量處理所有中文硬編碼 | 大規模重構、技術債務清理、ARB 建議生成 |
Style Guardian 的 i18n 檢查:
Text(), AppBar title, labelText/hintTexti18n Checker 的優勢:
uv run scripts/i18n_hardcode_checker.py
輸出:
i18n 硬編碼檢查結果:
總計: 11918 處
lib/: 1966 處
test/: 9952 處
uv run scripts/i18n_hardcode_checker.py --report > docs/i18n-report.md
生成 Markdown 格式的詳細報告,包含:
uv run scripts/i18n_hardcode_checker.py --arb
生成 JSON 格式的 ARB 鍵值建議:
{
"suggestedKey": {
"value_zh": "原始中文字串",
"value_en": "[TODO: 原始中文字串]",
"description": "From file_path:line_number"
}
}
uv run scripts/i18n_hardcode_checker.py --json
生成結構化 JSON 資料,適合程式處理:
{
"summary": {
"total": 11918,
"lib": 1966,
"test": 9952
},
"items": [...]
}
# 執行檢查
uv run scripts/i18n_hardcode_checker.py
# 如果發現大量硬編碼,生成報告
uv run scripts/i18n_hardcode_checker.py --report > docs/i18n-report.md
根據報告,將硬編碼分為:
| 分類 | 處理方式 |
|---|---|
| UI 層 (presentation/) | 直接使用 l10n |
| ViewModel 層 | 返回代碼,讓 UI 處理 |
| Domain/Model 層 | 移除 UI 文字,改用代碼 |
| Test 層 | 使用 MockAppLocalizations |
對於大量硬編碼:
uv run scripts/i18n_hardcode_checker.py --arb > arb_suggestions.json
flutter gen-l10n# 再次檢查
uv run scripts/i18n_hardcode_checker.py
# 確認數量減少
大規模 i18n 技術債務的有效處理策略。
不同複雜度使用不同處理手段,最大化效率和品質
| 等級 | 描述 | 處理策略 | 範例 |
|---|---|---|---|
| A | 簡單 UI 文字 | 腳本自動替換 | Text('確認') → Text(l10n.confirm) |
| B | 需評估內容 | 多代理人平行處理 | ViewModel 層訊息 |
| C | 需架構重構 | 建立獨立 Ticket | Domain 層硬編碼 |
| D | 測試檔案 | 逐案評估 | 測試輸出訊息 vs 驗證條件 |
等級 A - 簡單 UI 文字:
presentation/ 或 core/ui/ 目錄等級 B - 需評估內容:
等級 C - 需架構重構:
等級 D - 測試檔案:
針對等級 A,使用批量替換腳本:
# Dry run(預設)
uv run scripts/i18n_batch_replace.py --target lib/presentation
# 實際替換
uv run scripts/i18n_batch_replace.py --target lib/presentation --apply
# 生成報告
uv run scripts/i18n_batch_replace.py --target lib/presentation --report
腳本會自動處理常見映射:
1. 分析階段
└─ uv run scripts/i18n_hardcode_checker.py --json
└─ 將結果分類為 A/B/C/D 等級
2. 等級 A 處理
└─ 新增 ARB 鍵值
└─ flutter gen-l10n
└─ uv run scripts/i18n_batch_replace.py --apply
3. 等級 B 處理
└─ 多代理人平行評估
└─ 決定各項目歸屬(A/C/保留)
4. 等級 C 處理
└─ 建立 Atomic Tickets
└─ 按依賴順序排程
5. 等級 D 處理
└─ 逐案評估
└─ 不跳過,記錄評估結果
當發現等級 C(需架構重構)項目時:
| 情況 | 處理方式 |
|---|---|
| Domain 層包含 UI 文字 | 建立重構 Ticket(如 W2-001) |
| 默認參數硬編碼 | 建立策略 Ticket(如 W2-002) |
| 跨多檔案的模式 | 建立批量處理 Ticket |
v0.25.1 i18n 技術債務處理:
| 等級 | 數量 | 處理方式 | Ticket |
|---|---|---|---|
| A | 35 處 | 腳本替換 | W1-004 |
| B | 90 處 | 待評估 | W1-004 |
| C | 947 處 | 架構重構 | W2-001 |
| C | 3 處 | 默認參數 | W2-002 |
腳本會自動排除以下模式:
腳本會根據中文內容自動建議鍵名:
| 中文關鍵字 | 英文對應 |
|---|---|
| 成功 | success |
| 失敗 | failed |
| 錯誤 | error |
| 匯入 | import |
| 匯出 | export |
| 書籍 | book |
| 載入 | loading |
| 完成 | completed |
# 先執行 style guardian 檢查
/style-guardian
# 再執行 i18n 檢查
uv run scripts/i18n_hardcode_checker.py
可在 CI 中加入:
- name: Check i18n
run: |
result=$(uv run scripts/i18n_hardcode_checker.py --json)
lib_count=$(echo $result | jq '.summary.lib')
if [ $lib_count -gt 100 ]; then
echo "Warning: $lib_count hardcoded strings in lib/"
fi
建立日期: 2026-01-14 更新日期: 2026-01-15 維護者: 主線程 腳本位置:
scripts/i18n_hardcode_checker.py - 硬編碼檢查腳本scripts/i18n_batch_replace.py - 批量替換腳本xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience