Skip to content

fix(plugin-audit): localize activity summaries to the workspace locale (#3039)#3045

Merged
os-zhuang merged 1 commit into
mainfrom
fix/plugin-audit-summary-i18n-3039
Jul 16, 2026
Merged

fix(plugin-audit): localize activity summaries to the workspace locale (#3039)#3045
os-zhuang merged 1 commit into
mainfrom
fix/plugin-audit-summary-i18n-3039

Conversation

@baozhoutao

Copy link
Copy Markdown
Contributor

Closes #3039

Problem

installAuditWriters hardcoded English verbs and the object API name into every activity summary — Created person_qualification "OC-00001" — regardless of the workspace localization.locale setting (ADR-0053). The summary is baked into the sys_activity row at write time, so no UI-side fix is possible.

Fix

  • writeAudit resolves the workspace default locale per write through a new lazy getLocale seam (resolveLocalizationContext), memoized per tenant/user scope with a 30s TTL so audit logging adds no settings query to the CRUD hot path.
  • Create/delete and the generic update fallback render through new messages.activityCreated/Updated/Deleted i18n templates; en / zh-CN / ja-JP / es-ES ship in the plugin bundle. zh-CN yields the issue's expected 创建了 人员资质 "OC-00001".
  • The object is named by its localized label (objects.{name}.label) → authored def label → API name.
  • i18n resolves through a structural AuditI18nSurface seam (mirroring MessagingEmitSurface); missing i18n/settings services or bundle keys degrade to the previous English summaries, so existing deployments are unaffected.
  • Message keys are single-segment (activityCreated) because both i18n implementations (memory fallback + FileI18nAdapter) resolve dot-paths by walking nested objects — a flat dotted record key would never resolve.
  • Author-owned milestone and tracked-change summaries are intentionally untouched (their wording belongs to the app author).

Tests

pnpm --filter @objectstack/plugin-audit test — 38/38 (6 new: zh-CN create/delete/update summaries via the real createMemoryI18n + shipped bundle, def-label fallback, no-i18n degradation, locale memoization). Build + DTS green. Patch changeset included.

Related UI-side fix (list/detail relative-date humanize, #3040): objectstack-ai/objectui PR from branch claude/framework-issues-3040-3039-b413f4.

@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jul 16, 2026 10:18am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/plugin-audit.

4 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/deployment/production-readiness.mdx (via @objectstack/plugin-audit)
  • content/docs/getting-started/cli.mdx (via @objectstack/plugin-audit)
  • content/docs/plugins/packages.mdx (via @objectstack/plugin-audit)
  • content/docs/releases/implementation-status.mdx (via @objectstack/plugin-audit)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

#3039)

Activity writers hardcoded English verbs and the object API name
(`Created person_qualification "OC-00001"`) regardless of the workspace
localization.locale setting. writeAudit now:

- resolves the ADR-0053 workspace locale per write via a lazy getLocale
  seam (resolveLocalizationContext), memoized per tenant/user scope with
  a 30s TTL so audit logging adds no settings query to the CRUD hot path
- renders create/delete and the generic update fallback through new
  messages.activityCreated/Updated/Deleted i18n templates (en, zh-CN,
  ja-JP, es-ES shipped in the plugin bundle); keys are single-segment
  because both i18n implementations resolve dot-paths by walking nested
  objects
- names the object by its localized label (objects.{name}.label), falling
  back to the authored def label, then the API name

Both services resolve lazily through structural seams (AuditI18nSurface,
mirroring MessagingEmitSurface); missing i18n/settings or bundle keys
degrade to the previous English summaries.
@os-zhuang
os-zhuang merged commit 21f75ce into main Jul 16, 2026
16 checks passed
@os-zhuang
os-zhuang deleted the fix/plugin-audit-summary-i18n-3039 branch July 16, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plugin-audit] 活动 summary 硬编码英文动词 + 用对象 API 名(非 label),无 i18n(zh-CN 显示 Created os_xxx)

2 participants