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 6d0089c
Browse filesBrowse the repository at this point in the historyBrowse files
fix(objectql,approvals,audit): rule messages, approval object labels and activity-summary labels read as /meta serves them in a declared sourceLocale (#36464)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9Ubb3T2gwH6MWTYde4qF8edEDN)_
Part of #35384 — this PR moves three of the card's readers onto the
`/meta` resolve path. The approval NOTIFICATION subject param stays
open: it is resolved per recipient at delivery by service-messaging's
general keyed-param path, so it is left for the area to file (see
Acceptance notes).
Clause-②: no
Metadata-protocol: none
## 维护者速读
-
用户能看到什么变化:应用以英文编写、默认面向中文用户时,英文用户在审批收件箱、审批页、活动记录摘要和自定义校验规则的报错里看到英文原文,不再夹杂默认语言的中文;中文用户看到的不变。
- 为什么做:这是多语言标签统一的后续:让这三处和对象元数据接口用同一种方式取标签。
- 出错会怎样:最坏情况是某处标签显示成原文而不是译文,不影响数据和权限,合并后可直接回退。
- 要你做什么:无
## What changes
The #34030 rule, quoted from the card: "resolve the label through
`translateObject` with the same resolve options `/meta` builds, so `t()`
carries messages only."
- **objectql** (`validation/rule-validator.ts`, `authoredRuleMessage`):
an author-written rule message
(`objects.OBJECT._validations.RULE.message`) now resolves through
`translatedLabels` over `ValidationMessageContext.labelTranslation`.
That is the bundle plus `ResolveOptions` that the same refusal's field,
option and object labels already read (#34030), so this half adds no
copy of the options. The ADR-0029 D9.2a tenant-rewrite check is
unchanged. `translate` (that is, `t()`) now carries only the built-in
messages.
- **plugin-approvals** (`reader-locale-labels.ts`,
`readerLabelsFor().objectLabel`): the object label resolves through
`translateObject` over every locale the service holds, with the metadata
route's options: the negotiated reader locale, the declared fallback
chain, and `sourceLocale` else `defaultLocale`. This one change covers
the inbox row, the request page, the generic data door's request rows
and the two lifecycle refusals that name an object. Flow, step and
position labels and the catalog sentences stay on `t()`.
- **plugin-audit** (`activity-summary-message.ts`):
`readerSummaryLocale` hands the composer the object definition that
`translateObject` put in the reader's language. The object, field and
select-option labels are read off that definition and no longer come
from `t()` keys. The writer's stored sentence is unchanged, because its
locale already reads only authored labels.
- A service that cannot hand its translations over (no `getLocales()` /
`getTranslations()`) no longer gets these labels translated through
`t()`: the authored text stands. Every service the platform ships
implements both.
## Tests
- objectql `engine-label-source-locale.test.ts`: new top-level describe
for the authored rule message under `sourceLocale: 'en'` /
`defaultLocale: 'zh-CN'`. An `en` write reads the authored sentence.
Controls: a `zh-CN` write reads the zh-CN row, and with no
`sourceLocale` an `en` write walks to the zh-CN row.
- objectql `validation/rule-validator.test.ts` (#14253 and D9.2a
describes) moved from `translate` doubles to `labelTranslation`. The
first case wires a `t()` decoy beside it, so a regression back to `t()`
turns it red.
- objectql `engine-validation-locale-negotiation.test.ts` and
`engine-validation-tenant-rewrite.test.ts`: the served-adapter doubles
gain `getTranslations` / `getFallbackLocale`, which `FileI18nAdapter`
has. The three `t()`-locale probes in the negotiation suite now trip a
built-in `max_length` message, the sentence the `t()` bridge still
carries.
- plugin-approvals `reader-locale-labels.test.ts` and plugin-audit
`activity-summary-message.test.ts`: a new `[#35384]` describe in each.
Each covers the real in-memory service and the served-adapter shape, and
asserts that `t()` itself answers the zh-CN row at the same service, so
the defect's precondition is measured and not assumed. Also covered: the
two controls, a `t()`-only service, and a throwing `getTranslations`.
- `/meta`'s half of the same scenario is pinned in
`packages/rest/src/meta-i18n-declared-fallback-chain.test.ts` §6.
## Acceptance notes
- **Not fixed here, left for the area to file:** the approval
notification subject param (`approval-notification-text.ts`
`subjectParams`, `{ key: objects.OBJECT.label, fallback }`). It is
resolved at delivery by
`packages/services/service-messaging/src/notification-text.ts`
(`renderWith`: `lookup(i18n, param.key, locale) ?? param.fallback`,
through `t()`). The producer holds no recipient locale at emit, so it
cannot hand over a resolved label. The only messaging fix would parse
the key shape inside the per-delivery param resolver that every
producer's keyed params share, which goes past the narrow widening the
area allowed. **Routed (seat):** this is the #35384 remainder, released
back to `pm:queue` on merge as a typed object-label param in
`NotificationTextKeys` that service-messaging resolves through
`translateObject` (`domain:server`), together with `readerLabelsFor`'s
flow, step and position labels.
- **Folded into the same #35384 remainder (L1 7081082388):** the two
readers this PR moves hand `translateObject` the metadata route's
resolve options but not its packaged base. plugin-approvals
`objectLabel` passes `{ name }` alone, and plugin-audit
`translatedObjectDef` passes no `packagedBase`. So for a renamed object
(a served label that diverged from the packaged one) they read the
translation of the old label, where `/meta` serves the rename. This is
not a regression: `t('objects.<o>.label')` did the same. The fix is the
`getPackagedObjectBase` read #36460 threads for the share-link label.
Until then, the docblocks' "as `/meta` resolves it" holds for the
resolve options only.
- **Measured: `en-US` under `sourceLocale: 'en'`.** `/meta` hands
`translateObject` the request tag as written. objectql (#34030) and now
these readers hand it the tag negotiated against the service's locales.
When the service holds an `en` locale (any `en` catalog), an `en-US`
request gets `客户` (the defaultLocale row) from `/meta` and `Account`
from objectql. With no `en` locale held, both give `客户`. Reading taken
with `translateObject` from this branch's `@objectstack/spec` dist at
c0111e2. Raised as a decision; not changed here. **Filed:** #36466
(`/meta` negotiates the request locale first; no spec change).
- No resolve-options builder is reachable from plugin-approvals or
plugin-audit: rest's `metaTranslateOptions` is not a dependency, and
objectql's `labelTranslationOf` is private. So each plugin carries the
same few lines that plugin-security and objectql inlined in #34030, with
a docblock naming `metaTranslateOptions`. **Filed:** #36467 (one
exported spec builder, contract tier).
## Verification
Two-minute check: `pnpm --filter @objectstack/plugin-approvals exec
vitest run --maxWorkers=2 src/reader-locale-labels.test.ts`. Expect
every case to pass, including `[#35384] … an en reader picks no
defaultLocale row`.
Read first:
1. `packages/plugins/plugin-audit/src/activity-summary-message.ts`, the
`readerSummaryLocale` / `translatedObjectDef` hunk (the reader's
definitions are now the translated ones).
2. `packages/objectql/src/validation/rule-validator.ts`, the
`authoredRuleMessage` hunk.
3. `packages/plugins/plugin-approvals/src/reader-locale-labels.ts`, the
`objectLabel` hunk.
<details><summary>Test readings (b815112 unless stated; fix round at
final head 67d23af first)</summary>
- Fix round at 67d23af (CI Test Core 6/10 red on b815112: 4 cases in
`packages/services/service-automation/src/flow-write-refusal-locale.integration.test.ts`,
whose i18n double held the rule message only as a `t()` key, so the
bundle read now returned the authored English). The double's zh-CN
bundle gains
`objects.crm_deal._validations.amount_not_negative.message`. It is a
fixture change of spelling only: no assertion changed and nothing was
skipped. In that file, Tests 8 passed (8).
`@objectstack/service-automation` 290/290 files, 4222/4222 tests.
`@objectstack/plugin-approvals` 126/126 files, 1853/1853.
`@objectstack/plugin-audit` 109/109 files, 1800/1800. Lock VERDICT
command-exit 0. overlap-check at 67d23af is clean. A sweep of the
other tests that combine validations, an i18n service and a non-en
locale found no further consumer.
- objectql `pnpm --filter @objectstack/objectql test` at 8be4929
(objectql is unchanged after it): Test Files 628 passed (628), Tests
14286 passed (14286); lock VERDICT command-exit 0.
- plugin-audit `pnpm --filter @objectstack/plugin-audit test` at
b61713e: 107/109 files, 1798/1800 tests. Two failures: the new pin's
expected list wording, and the bare-string option case (triaged below).
After the fix, those two files at b815112: Tests 31 passed (31).
- plugin-approvals `pnpm --filter @objectstack/plugin-approvals test` at
b61713e: 125/126 files, 1846/1853 tests. Seven failures, all in
`record-lock-user-facing-message.test.ts`, whose doubles answered labels
through `t()` only. After those doubles gained `getTranslations`, that
file and `reader-locale-labels.test.ts` at b815112: Tests 41 passed
(41).
- typecheck at b815112: objectql exit 0, plugin-audit exit 0,
plugin-approvals exit 0. At b61713e approvals failed with TS2339 on
the label-only doc literal; fixed with an `ObjectLike` annotation.
- Fixture triage: the bare-string option `options: ['p1', 'p2']` is not
a `SelectOptionSchema` (strict object with `label`). `translateObject`,
and so `/meta`, serves it as written. The #7289 case now pins `p1` as
`/meta` serves it, where it used to pin the `t()` row.
</details>
<details><summary>Reverse verification (each fixed source file put back
to origin/main, its pins run, then restored)</summary>
At b61713e, under one lock call, the scratch script used `git restore
--source=BASE` (tree only), checked the BASE blob hash on disk, then
`git checkout HEAD --` and checked the HEAD blob hash. Pins resolve
`src/` directly, so no dist step is involved.
- `rule-validator.ts` at BASE: `engine-label-source-locale.test.ts` 1
failed / 8 (`an en write reads the authored English sentence`).
- `reader-locale-labels.ts` at BASE: `reader-locale-labels.test.ts` 4
failed / 22 (both `en reader picks no defaultLocale row` cases, the
inbox-row case, and the `t()`-only case).
- `activity-summary-message.ts` at BASE:
`activity-summary-message.test.ts` 4 failed / 18 (both `en reader`
cases, the `t()`-only case, and the throwing-translations case).
- Controls stayed green on every leg. After restore, `git diff HEAD` was
empty.
</details>
<details><summary>Gates</summary>
`node scripts/pm/dispatch-gates.mjs --commands` derived 74 families;
reconciliation with `--ran` reported 74 derived, 74 run.
- 70 exit 0 at b61713e. Re-run at b815112, exit 0:
`check:type-check-debt` (a PREREQUISITE exit 3 on the first pass, while
a sibling build held dist), `check:type-check-coverage`,
`check:cross-package-test-inputs`, `check:test-source-alias`,
`check:undeclared-dep-imports`, `check:nul-bytes`,
`check:engine-double-contract`, `check:doc-authoring`,
`check:issue-citations`.
- NOT MEASURED locally, left to CI: `check:i18n` (needs the built CLI
closure), `check:dual-build-cjs-loads` (needs a full build), and
`check-plugin-teardown-shape --self-test` (needs a commit this shallow
clone does not have).
- `overlap-check --branch=HEAD`: clean against origin/main and #36399.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jTyyBmoPBsURQjeJGq)_
<!-- signed: repo:objectstack#7 · zhuangjianguo ·
session_01QsR2jTyyBmoPBsURQjeJGq -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
fix(objectql,approvals,audit): an authored rule message, an approval's object label and an activity summary's labels read as `/meta` serves them in a declared `i18n.sourceLocale`
8
+
9
+
Clause-②: no
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, say), three readers still looked metadata text up through `II18nService.t()`, which falls back to the `defaultLocale` row when the reader's locale holds no entry. An `en` reader was shown the Chinese text where `GET /meta` and every other refusal label showed the English one as authored:
13
+
14
+
- objectql: the author-written message of a validation rule (`objects.<object>._validations.<rule>.message`) in a `400 VALIDATION_FAILED` refusal;
15
+
- plugin-approvals: the object label on the approvals inbox, the request page, the generic data door's request rows and the approval refusals that name an object;
16
+
- plugin-audit: the object, field and select-option labels inside an activity summary composed in the reader's language.
17
+
18
+
Each now resolves through `translateObject` (`@objectstack/spec/system`) over every locale the i18n service holds, with the resolve options the metadata route builds: the reader's locale, the declared fallback chain and the authored language (the declared `sourceLocale`, else `defaultLocale`). A reader in the authored language reads the text as written; every other reader reads the same row as before. `t()` keeps carrying the catalog sentences.
19
+
20
+
An i18n service that cannot hand its translations over (no `getLocales()` / `getTranslations()`) no longer has these labels and rule messages translated through `t()`: the authored text stands. Every service the platform ships implements both.
0 commit comments