Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
8.3 KiB
Context
The product design is docs/superpowers/specs/2026-12-02-zh-cn-messages-design.md (owner approval 2026-12-02). Facts from the codebase:
- The portal side already exists. It came over from babyboo:
app/lib/server/messages.tsloads the catalog keyed on the catalog version;app/lib/server/locales.tsloads the language list, from the admin path with a session and the public path without one;app/lib/i18n/t.tsresolves the catalog, then the built-in English, then the code;- the language switcher, and the guard test that keeps every visible label on
t().
- The backend side is missing. mobile-api answers 404 on
/api/admin/messages/catalog/{locale},/api/admin/messages/catalog-version,/api/admin/localesand/api/public/locales. services-system has/message/*reads and a plain save, but nosupported_locale, nocatalog_meta, no search and no save checks. - The data.
service-system.messageholds about 3,400 area-Arows from Tastefully, with JSONcontentper language. Only 43 of the 643 portal labels have a row, and 4 of those would change visible English. - The gateway lets any URL containing
/message/through without a user token. babyboo narrowed this to exact read paths. - Error shape. services-system answers refusals as ProblemDetail, with the reason in
detail. The core handler wins over service-level advice (memorycounter-error-body). mobile-api reads the reason fromdetail. - Source to port: babyboo
~/Projects/babyboo:- specs
locale-registry,admin-portal-locale-ui,message-admin-api,catalog-cache-invalidation,admin-portal-i18n; - code
SupportedLocale*,CatalogVersionService,MessageService,MessageController,AdminLocaleController,AdminMessageController; - portal
app/locales,app/messages,app/api/locales,app/api/messages.
- specs
Goals / Non-Goals
Goals: everything in the spec delta.
Non-goals:
- the visitor pages' own wording and the emails;
- Malay, Traditional Chinese and Indonesian text;
- babyboo's currency screens and the customer-portal areas (
AP,M); - adding or deleting labels from the screen.
Decisions
-
Port, trimmed to Co-Lite. These babyboo parts stay out, because nothing in Co-Lite uses them and the customer portal is not deployed:
- the Area filter: the Translations page and the export work on area
Aonly; - the add-label form: labels come with releases, and staff only translate;
- the currency endpoints.
Everything else follows babyboo's rules, which are listed in the specs above and turned into tests before the screens are built.
- the Area filter: the Translations page and the export work on area
-
services-system:
SupportedLocale(tablesupported_locale: id, unique code, label, enabled, sort_order) under/locale/*:findAll,findAllEnabled,findById,save,update. It refuses with the reasonsLocalesDuplicateCode,LocalesCodeLocked,LocalesFallbackLockedandLocalesLastEnabledLocked.catalog_meta(one row,id = 1), bumped by an atomic single-row update in the same transaction as every message save or import and every locale save or update. A refused write does not bump./message/catalogVersion./message/search: searchKey matches the code,en_USorzh_CNignoring case;missingLocale=zh_CNmatches absent, blank or equal to English; area filter; paged and sorted by code./message/saverefuses a code or area change (MsgsCodeAreaLocked) and a duplicate code in an area, ignoring case (MsgsDuplicateCode), and returns failures instead of swallowing them.
-
mobile-api:
AdminLocaleController:GET /api/admin/localesfor any signed-in admin;POSTandPUT /{id}underBO_LOCALES.GET /api/public/locales: enabled only, no session.AdminMessageControllerunderBO_MESSAGES:GET messages(search, missingLocale, page),GET messages/{id},PUT messages/{id}(the path id wins over the body),GET messages/export,POST messages/import(per-row upsert, matched by code ignoring case within areaA, summary{created, updated, errors[{index, code, error}]}).GET messages/catalog/{locale}andGET messages/catalog-versionneed the API key but no session.- Refusal reasons pass through as 409s.
@Auditedcovers PUT, import, export (a sensitive read) and the locale writes.
-
Gateway. Replace the
url.contains("/message/")bypass with exact read paths:/message/catalogVersion,/message/getAllMessages/,/message/getMessageJsonForMobile/and any other read in use today (check callers first), plusGET /locale/findAllEnabled. Saves, search,findAlland the locale writes then need the user token that mobile-api already forwards. This is security code, so the whole diff is read in review. -
Portal:
/localesand/messagespages, ported with the edit panel (MessageEditSheet) and the import dialog;- route handlers under
app/api/locales/**andapp/api/messages/**, forwarding the session token; routeModulesentries;- the sidebar System section gets
BO_MESSAGES(iconLanguages) andBO_LOCALES(iconGlobe), after Audit log. - After sign-in the portal refreshes its server components, so the language list reloads (babyboo
admin-locales-after-login); check whether Co-Lite already does this.
-
Modules and SQL (change folder
sql/, mirrored intolocal/seed/):01-locales.sql(DDL:supported_localewith the five rows,catalog_metaat version 0);02-modules.sql(BO_MESSAGES,BO_LOCALES, area BO, parent System, granted to no role);03-zh-cn-messages.sql(generated);99-rollback.sql.
The local seed appends
01and02to03-colite.sqland adds04-zh-cn-messages.sql. -
The Chinese:
solvway-admin-portal/app/lib/i18n/zh_CN.seed.jsonmaps eachdefaultMessages.tskey to its Chinese.npm run i18n:sqlwrites03-zh-cn-messages.sqlfromdefaultMessages.tsand the JSON:- for each key, insert the area-
Arow withen_USandzh_CNwhen no row matches the code ignoring case; - otherwise
JSON_SETitszh_CN; - set
en_USfor the four conflicting codes (LogIn,Member,Wallet,Tree); - bump
catalog_meta.
- for each key, insert the area-
- Tests:
- every key has non-empty Chinese;
- the placeholder sets are equal;
- no extra keys in the JSON;
- the committed SQL equals the generator output.
- Glossary: lead 线索, event lead 活动线索, salesperson 销售员, interest 兴趣, role 角色, check-in 签到, event 活动, user 用户, company 公司, dashboard 仪表板, audit log 审计日志. WhatsApp, QR and company codes stay as they are.
- Later changes add their new keys to the JSON and ship an insert-if-missing SQL for those keys only.
-
The four English rows. They hold Tastefully MLM wording that only the undeployed customer portal reads. Setting them to the portal's English is the smallest fix. Deleting them would change that portal more.
Risks / Trade-offs
- Narrowing the gateway can break a caller that relied on the open
/message/prefix, such as the customer portal or a service. Mitigation: grep every/message/caller before narrowing, and run the full backend verify. - Catalog English now overrides the built-in English for any key that has a database row. The SQL aligns the four known conflicts. A guard test compares the generated SQL's English with
defaultMessages.ts, and the live check signs in in English. - First-pass Chinese can read machine-like. It is marked for review. The Missing Chinese filter and export/import make the review cheap. The deployment doc says so.
- The catalog read is public. It is label text only, behind the API key, and babyboo makes the same call.
- The repo seed and the database can drift after staff edits. The JSON is a seed, not the source of truth. Later SQL only inserts what is missing, so edits are never overwritten.
Migration Plan
- Run
sql/01-locales.sql(DDL),sql/02-modules.sqlandsql/03-zh-cn-messages.sql. - Deploy services-system, the gateway, mobile-api and the portal.
- A super admin checks the back office in 简体中文 and grants
BO_MESSAGESto the reviewer's role if needed.
Rollback: sql/99-rollback.sql drops the two tables and the modules. The Chinese text stays in message, which is harmless with the previous images, because they never read it.