agentleFS
TienDat-VnaTienDat-Vna/BackSpec/.claude/skills/multi-language-error-handling/SKILL.md

multi-language-error-handling

Skill1 starsChanged 46 days agoMITView on GitHub

Hướng dẫn quản lý từ điển đa ngôn ngữ (VI/EN) lưu trong cơ sở dữ liệu tbl_lang, nạp vào bộ nhớ qua LangService và đồng bộ sự kiện qua Redis Pub/Sub.

The file

Files
SKILL.md
<!-- GENERATED FROM registry/skills/multi-language-error-handling/SKILL.md — DO NOT EDIT DIRECTLY --><!-- GENERATED FROM .shared/skills/02-codestyle/multi-language-error-handling/SKILL.md — DO NOT EDIT DIRECTLY -->

Quy Trình Quản Lý & Xử Lý Lỗi Đa Ngôn Ngữ (i18n LangService)

1. Mục Đích

Hướng dẫn cơ chế hỗ trợ đa ngôn ngữ động cho mã lỗi và thông báo hệ thống, cho phép cập nhật từ Admin / Backoffice mà không cần redeploy code.


2. Kiến Trúc Hoạt Động

sequenceDiagram
    autonumber
    actor Admin as Admin System
    participant DB as Database (tbl_lang)
    participant Redis as Redis (system_channel)
    participant LangSvc as LangService (In-Memory Cache)
    participant API as Backend Service

    Admin->>DB: Cập nhật thông điệp lỗi (message_vi, message_en)
    Admin->>Redis: PUBLISH system_channel '{"event":"RELOAD_LANG"}'
    Redis->>LangSvc: Kích hoạt reload()
    LangSvc->>DB: SELECT * FROM tbl_lang
    LangSvc->>LangSvc: Cập nhật ConcurrentHashMap trong RAM
    
    API->>LangSvc: getMessage("400010", "vi")
    LangSvc-->>API: "Khách hàng đã có tài khoản chứng khoán"

3. Quy Ước Viết Code

  1. Mọi Exception ném ra từ Service phải dùng Enum ErrorCodeDetail (ví dụ: ErrorCodeDetail.CUSTOMER_ALREADY_EXISTS).
  2. APIExceptionHandler sẽ gọi langService.getMessage(error.code, locale) để dịch ra ngôn ngữ của client theo header Accept-Language.
  3. Fallback: Nếu không tìm thấy key trong database, LangService sẽ sử dụng message mặc định khai báo sẵn trong enum ErrorCodeDetail.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.