You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 99ece3c
Browse filesBrowse the repository at this point in the historyBrowse files
fix(i18n): approval step label and approval notification object label read as /meta serves them (#36620)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9DD8XEF1VwrqXiQzo8zQCjY)_Fixes#35384
Clause-②: yes (widening)
Metadata-protocol: none
Skills-docs: none — Metadata-protocol is none and there is no
(narrowing) arm; no skills/** file teaches either label reading
## 维护者速读
-
用户能看到什么变化:在「编写语言与默认语言不同」的部署里(例如英文编写、用户默认中文),英文读者在审批收件箱和审批页上看到的审批步骤名,以及英文收件人收到的审批通知里的对象名,改为作者原文,不再混入中文;对象在代码里改过名的,通知里显示新名。
- 为什么做:这是「审批与审计文案按元数据接口同一方式取标签」那张卡的最后两项,前两批已合并,本次合并后该卡关闭。
-
出错会怎样:只影响审批步骤名和通知里的对象名这两处显示文字,取不到时退回原先存下的文字,不会让审批或通知失败;改动可整体撤回,已存的通知照旧显示。
- 要你做什么:无。
## What changes
The rule this card carries (from #34030): "resolve the label through
`translateObject` with the same resolve options `/meta` builds, so `t()`
carries messages only". This PR delivers the card's two remaining items
(items 2 and 3 landed in #36464 and #36598).
**1. Approval notification object label (service-messaging,
plugin-approvals).**
- `NotificationTextKeys.params` accepts a new value, `{ object:
'OBJECT_API_NAME', fallback }` (`NotificationObjectLabelParam`, exported
from `@objectstack/service-messaging`). `renderWith` resolves it through
`translateObject` (`@objectstack/spec/system`) over the object's served
definition (`getSchema`) and its packaged base
(`registry.getPackagedObjectBase`), both read off the data engine the
renderer already holds. The resolve options are `/meta`'s: the
recipient's negotiated locale, the declared fallback chain, and the
declared `sourceLocale` else `defaultLocale`, inlined as
`reader-locale-labels.ts` does (one exported builder is #36467).
`fallback` is delivered when nothing resolves.
- The inline fan-out, the dispatcher (claimed rows and digests) and the
inbox reader (`renderForReader`) all go through `renderWith`, so all
four paths resolve the label the same way.
- Widening, not replacement: `{ key, fallback }` is still accepted and
still renders through `t()`, so stored outbox and inbox rows render
exactly as before. The closed-shape validator (`problemOf`) admits the
new shape and refuses a mixed one, a missing `fallback`, or a name that
is not an object API name. The name shape is one segment of the existing
catalog-key shape, so every object a `{ key: 'objects.OBJECT.label' }`
param could name, the typed param can name too.
- plugin-approvals `subjectParams` now emits `{ object: objectName,
fallback }`.
**2. Approval step label (spec, plugin-approvals).**
- New spec export `resolveFlowApprovalStepLabel(bundle, flowName,
nodeId, literal?, opts?)` in
`packages/spec/src/system/i18n-resolver.ts`. It is the one reading of
`flows.FLOW.approvals.NODE_ID.label`, using the same locale chain and
the same bundle-then-literal order as `resolveFlowScreenTitle`.
- `reader-locale-labels.ts` `stepLabel` resolves through it with the
`/meta` resolve options it already builds for the flow, object and
position labels. No key is asked of `t()` any more.
- `translateFlow` is unchanged and stays unregistered in
`translateMetadataDocument`.
- Liveness `flows.approvals.label` evidence is re-anchored on the spec
resolver.
### Export choice (seat ruling, premise measured)
The seat ruled: overlay the step label inside `translateFlow` if the
step-label read points already hold or read the flow document; otherwise
use `resolveFlowApprovalStepLabel`. Measured at `aff34baea`:
- `reader-locale-labels.ts:405-410` (`localizeRequestLabels`) has only
`process_name` and `current_step` from the stored row. No flow document
is in hand. It is called for every row of a list read
(`approval-service.ts:10921`, `listRequests`), for the single read
(`:11205`), and by the generic data door
(`reader-locale-labels-middleware.ts:104`). Getting a document there
would add one flow read per row.
- `flowLabel` (`reader-locale-labels.ts:359`) does not read the flow
document. It hands `translateFlow` a stub, `{ name: flowName }`. So do
the other `translateFlow` callers in the tree:
`ui/packages/app-shell/src/views/FlowRunner.tsx:445` and
`ui/packages/plugin-detail/src/stageChangeStarts.tsx:106` both pass `{
name, label }`.
- Only the single-read enrichment holds the document
(`approval-service.ts:11340` `requestFlow`, used by `attachFlowSteps`
`:11350` and `attachFlowRoute` `:11407`).
The premise does not hold at the main read point, so this PR takes
`resolveFlowApprovalStepLabel`. `translateFlow` and its docblock are
untouched, so no client-visible change.
The param's member is `object`, by seat ruling (card comment
7091274184), and the type name stays `NotificationObjectLabelParam`.
Three reasons:
- The member holds the object's API name, not a label.
- In the spec, the word `object` always means an object's API name.
- The sibling `{ key, fallback }` is also named for what it holds.
The first round built it as `objectLabel` and round 2 renamed it. The
mixed shape `{ object, fallback, key }` is still refused.
### Tests changed (forced)
- `plugin-approvals/src/reader-locale-labels.test.ts`: two pins that
drove the step label through a `t()`-only double were re-triaged onto
`getTranslations`. One is "negotiates through `resolveBundleLocale`…"
and the other is "asks the service once per read, and never through
t()". The `#35384` flow/position sourceLocale describe now also covers
the step label.
- `plugin-approvals/src/no-approver-note.test.ts`: its local renderer
narrows the widened `ApprovalTextParam` union. TS2339 came from
`check:test-typecheck`, and no assertion changed.
## Tests
<details><summary>Readings</summary>
- New pins: spec `i18n-resolver.test.ts` describe
`resolveFlowApprovalStepLabel` (5 cases: locale + `zh` ladder, declared
chain, authored locale sourceLocale en / default zh-CN, literal and
empty-bundle fallbacks, own keys). service-messaging
`keyed-notification-text.integration.test.ts` describe `#35384` (7 cases
on a real ObjectQL + SqlDriver: precondition, inline fan-out, SQL outbox
+ dispatcher, renamed packaged object with `/meta`'s
`translateMetadataDocument` as oracle, inbox reader en / en-US / zh-CN,
`t()`-only service, closed shape). plugin-approvals
`approval-notification-keyed-text.integration.test.ts` describe
`[#35384]` (real ApprovalService plus real MessagingService: an en
approver reads `Deal`, a zh-CN approver reads `商机`, a renamed object
reads its rename).
- Full suites on `2dfa8720` (the code head; the later merge of
`origin/main` touched no file in these packages):
`@objectstack/service-messaging` Test Files 80 passed (80), Tests 1084
passed (1084); `@objectstack/plugin-approvals` Test Files 127 passed
(127), Tests 1883 passed (1883); `@objectstack/spec` (on `9d5362af`,
spec unchanged after) Test Files 880 passed (880), Tests 28058 passed, 1
todo. Typecheck of all three packages, including spec's
`check:test-typecheck` and approvals' `check:test-typecheck`: exit 0.
- Round 2, the rename of the member to `object`, at `cfce553f`: `pnpm
exec turbo run build` of both closures (40/40 tasks), then the typecheck
of service-messaging and plugin-approvals (including
`check:test-typecheck`) exited 0. `@objectstack/service-messaging` Test
Files 80 passed (80), Tests 1084 passed (1084).
`@objectstack/plugin-approvals` Test Files 127 passed (127), Tests 1883
passed (1883). The closed-shape pin still refuses `{ object, fallback,
key }`. Spec is unchanged in round 2.
- Ablation (round 1; one lock call each, `scripts/ablation-replace.mjs`
plus a trap restore; every subject resolves from `src/`, so there is no
dist leg; each leg's anchor went x1 to x0 and was restored with blob
equal to HEAD and `git diff HEAD` empty):
- Leg 1a, messaging object label read through `t()`: 5 failed / 7 of the
`#35384` describe.
- Leg 1b, no `packagedBase`: 1 failed / 7 (the rename case). The first
attempt was refused by the tool as a no-op (the replacement text already
existed elsewhere), so it was re-run with a distinct replacement.
- Leg 2, approvals `stepLabel` back on `t()`: 5 failed / 37.
- Leg 3, spec resolver walking the declared chain for the authored
locale: 1 failed / 5.
- Leg 4, approvals `subjectParams` back to `{ key }`: 2 failed / 8 (both
end-to-end `[#35384]` cases).
</details>
## Acceptance notes
- Version skew: an older `service-messaging` refuses `{ object, fallback
}` at `emit()`. Both packages are in the changeset `fixed` group, and
the changeset says to upgrade them together.
- A `t()`-only i18n double (no `getTranslations`) now gets the
`fallback` for the typed param, not the `t()` row.
`II18nService.getTranslations` is a required member, so every served
service hands its translations over.
- Other producers that name an object through `{ key:
'objects.OBJECT.label' }` keep the `t()` reading until they adopt the
typed param. Only plugin-approvals emits it today (`git grep
objectLabelKey` under packages/services and packages/plugins).
- CI on the round-1 head `0b91c34b`: Test UI, Lint & Repo Gates and
TypeScript Type Check read red, and none of them is a test or type
failure. Run 45109434849 concluded `cancelled` at 04:07:57Z because the
push of `cfce553f` (committed 04:07:17Z; its CI run 45109928513 was
created at 04:07:32Z) superseded it. Every Test UI, Test Core, Lint and
Type Check lane on `0b91c34b` concluded `cancelled` between 04:07:33Z
and 04:07:57Z. The three rollups only report that: Test UI logged "the
Test UI shards concluded 'cancelled'", Lint & Repo Gates logged "lint
lane ... concluded `cancelled`" for four lanes, and TypeScript Type
Check logged "type-check lane ... concluded `cancelled`" for three
lanes, with no `error TS` line. Nothing under `ui/**` or `examples/**`
consumes `NotificationTextParam`, `ApprovalTextParam` or the stored
`keyed_text` (`git grep`). The only in-repo narrowing site was
`no-approver-note.test.ts`, fixed in round 1.
## Verification
Read first:
`packages/services/service-messaging/src/notification-text.ts`
(`renderWith` and the private `objectLabel` resolver; risk: the
validator's new branch), `packages/spec/src/system/i18n-resolver.ts`
(`resolveFlowApprovalStepLabel`),
`packages/plugins/plugin-approvals/src/reader-locale-labels.ts`
(`stepLabel`).
Two-minute check: `pnpm --filter @objectstack/service-messaging exec
vitest run src/keyed-notification-text.integration.test.ts -t 35384`
should show 7 passed. The en recipient reads `Your Opportunity D_1
awaits approval.`, and the renamed object reads `Deal`.
https://claude.ai/code/session_01ADHkmQNmyLgnBbCoc2iFjL
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: repo:objectstack#2 · os-steve ·
session_01ADHkmQNmyLgnBbCoc2iFjL -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(i18n): an approval step label and an approval notification's object label read as the metadata translators serve them
8
+
9
+
Clause-②: yes (widening)
10
+
Metadata-protocol: none
11
+
12
+
In a deployment whose `i18n.sourceLocale` differs from its `i18n.defaultLocale` (an app authored in English that defaults its users to Chinese), an English reader was shown the Chinese approval step name, and an English approval-notification recipient read the Chinese object name inside an English sentence. Both labels were read through `II18nService.t()`, which falls back to the `defaultLocale` row; `/meta` serves the authored text. Both now resolve the way the metadata route resolves a label: the reader's negotiated locale, the declared fallback chain, and the authored language (the declared `sourceLocale`, else `defaultLocale`).
13
+
14
+
-**`@objectstack/spec`** adds `resolveFlowApprovalStepLabel(bundle, flowName, nodeId, literal?, opts?)` (`@objectstack/spec/system`), the one reading of `flows.<flow>.approvals.<node_id>.label`: the requested locale, then the declared fallback chain (skipped for the authored locale), then `literal`. It takes the flow's name and the node's id, so a reader holding only an approval request row needs no flow document.
15
+
-**`@objectstack/service-messaging`** accepts a new `NotificationTextKeys.params` value, `{ object: '<object API name>', fallback }` (`NotificationObjectLabelParam`): the label of that object in the recipient's language, resolved as `GET /meta/object/:name` serves it, by `translateObject` over the object's served definition and its packaged base, so a renamed packaged object is named by its rename. It renders the same way on the inline fan-out, the dispatcher (digests included) and the inbox reader. `fallback` is delivered when nothing resolves. The `{ key, fallback }` value is still accepted and still renders through `t()`, so stored deliveries and inbox rows render as before.
16
+
-**`@objectstack/plugin-approvals`** names a notification's object with that typed param, and reads the approval step label through `resolveFlowApprovalStepLabel`, so `t()` carries catalog sentences only.
17
+
18
+
Upgrade `@objectstack/plugin-approvals` and `@objectstack/service-messaging` together: an older messaging service refuses the typed param at `emit()`.
0 commit comments