Skip to content

Commit ee2ffca

Browse files
fix(lint,rest)!: i18n extract/check expect the _relatedLists keys os validate accepts under a .custom arrangement, and the object read translates a tab title the arrangement sets (#38085)
repo:objectstack#3 · os-tesla · session_01L9qibyUSf2nKJWW6qBemSU <!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoPitZDb578jbruHjEfhUY3D)_ Fixes #37622 Clause-②: yes (narrowing) Metadata-protocol: none Skills-docs: follow-up #38128 ## 维护者速读 - 定制包改过或新加了相关列表标签页标题时,翻译键命令和校验现在给出一样的结论;记录页上这类标题也会按定制包自己的译文显示,以前一直显示原文。 - 替给客户定制包做翻译的人解决两件事:覆盖率检查要求一个校验会拒收的键,永远过不了;定制包里新写的标签页标题翻了也不显示。 - 用 `--strict` 跑覆盖率检查的项目,可能新报缺少定制包标签页标题的译文,补上即可。显示侧最坏是某个标签页标题换成了定制包的译文。都可以直接撤回。 - 这是收窄,需要审批人批准;契约审核在 7ddcc64 上通过,没有必须改或应该改的项。d830f5af 只合入了 main,本 PR 自己的改动没有变。 ## What changes **`os i18n extract` / `os i18n check` agree with `os validate` (card item 1).** - New `packages/lint/src/related-list-titles.ts`: the ONE fold of an object's record-page tab titles as the registry serves them. It runs the owner's `relatedLists` first, then every list placement, then the paired `.custom` arrangement. Each arrangement entry replaces every entry it covers (`relatedListNameCovers`), in two passes per arrangement. It answers `labels` (list → served label + the layer that wrote it), `names`, `hidden` and `stripped`. The logic was lifted unchanged from `validate-translation-references.ts`, where it lived inline. - `validate-translation-references.ts` reads that fold. The rule's verdicts are unchanged; the 36595 pins and the full lint suite pass as before. - `i18n-walk.ts` `pushRelatedListLabels` (the walker behind `collectExpectedEntries`, which both CLI commands call) reads the same fold over the stack's `objectExtensions`: - no key over a list the arrangement hides, names bare or re-states without a `label`; - one key, carrying the arrangement's text, over a list the arrangement labels; - still no key for a label only a code extender's `place` entry gives. The rule accepts that key, but the registry does not apply a placement on a target with no `relatedLists`, or on a list the owner already names. - It lives beside `object-graph.ts`, not in it. That file's receivers are tabled by the security-posture rule's key-read meta-test, which this fold is no part of. - `packages/cli` is unchanged. **The object read translates a tab title the arrangement sets (card item 2, seat route R1).** - `packages/rest/src/meta-item-read-gate.ts`, new `objectPairRelatedListsBundleOf`. It is used by both `/meta/object` reads, `translateMetaDocument` (by name) and `translateMetaList` (list). - An object still answers no `servedOverrideBaseOf` (ADR-0146 D10, unchanged). Instead, the read takes the pair of the base the object's packaged base ships in (`packagedBase._packageId`, the base `withoutStaleObjectPlural` already reads) and calls `getPairTranslationBundle` through the same per-page memo. - Only the `objects.OBJECT._relatedLists` subtree of each locale is handed on, as the existing `pairBundle` option. - The pair is asked only when the served object carries a tab title that diverges from the packaged base (`hasRelatedListTitleOffBase`, the divergence `translateObjectRelatedLists` judges a title by). An object list where no arrangement changed a tab title pays no new translation read, which keeps the ADR-0090 D10 statement budget pinned by `packages/runtime/src/mcp-list-objects-statements.pin.test.ts`. - A tab title that diverges from the packaged base now reads the pair's translation, then keeps its own text. On such an object, a title equal to the owner's reads the pair's translation first, then the deployment's, interleaved by locale, as the spec's `labelCatalogs` already orders it. On an object where no title diverges, every title reads the deployment catalog, as before; that catalog already holds the pair's share. - Every other string of the object keeps the ranking it had. A slice that answers nothing for an object string reads exactly as no `pairBundle`; the scope pin below holds this. - No new export and no new option: `TranslateDocumentOptions` and `packages/spec/src/system/i18n-resolver.ts` are untouched. **Review follow-ups N2–N4.** - N2: a pin for `{ list: 'event.related_to', hidden: true }` beside a bare `'event'` (both orders). The wrong test comment that said the schema refuses that shape is removed. - N3/N4: - The two `translation-target-unknown` hints now name the list the key addresses (`{ list: 'LIST', label }`) instead of "the owner's `label`". - The stripped message says "replaces the entry that labelled it". - The ledger entry `translation-related-list-key-under-arrangement-refused`: its `surface` says "the owner or a list placement labels". Its `replacement` no longer claims a translated title needs the owner's label, which this PR makes false. - `content/docs/protocol/kernel/i18n-standard.mdx`: the `_relatedLists` row says the same. - `packages/objectql/src/registry-related-lists-label-translation-36528.test.ts`: the header now says how the REST read builds the pair bundle, instead of claiming it did when it did not. Changeset: `@objectstack/lint`, `@objectstack/rest` and `@objectstack/spec` patch, with the BREAKING note for the coverage gate's expected key set and an ADR-0087 `not-required (no-migration-prescription)` disposition. ## Tests - `packages/lint/src/i18n-related-lists-arrangement-36595.test.ts` (the existing harness): - New top-level `describe` "collectExpectedEntries — _relatedLists agree with the rule". Over nine arrangements, every key the extractor scaffolds is translated and judged by `validateTranslationReferences`, and none is refused. - The scaffolded keys and their source text are pinned per arrangement. - A placement-only label is not asked for and is still accepted. - The N2 pin. The no-label hint assertion now expects `{ list: 'contact', label }`. - `packages/rest/src/meta-object-related-list-pair-i18n.test.ts` (new; the real `SchemaRegistry` / protocol / `RestServer` harness of `meta-object-extension-plural-label.test.ts`, pair `translation` rows read through `getPairTranslationBundle`), on both `/meta/object` reads: - The pair translates a relabelled tab and a newly titled one in `zh-CN`; `en`, which the pair does not translate, keeps the arrangement's text. - A title the pair does not translate keeps its own text, never the base's translation of another string. - Scope: an extension's renamed object `label` is NOT translated by the pair's `label` row, while its tab title is. - Controls: with no arrangement, and with one that keeps the owner's title. The deployment translation serves, and the pair's own translation serves first where it ships one. - Statement budget: the pair's catalog is asked 0 times for an object with no arrangement or one that keeps the owner's title, and more than 0 times for one that relabels. - `packages/cli/test/i18n-coverage.test.ts`: two cases, the zh keys `os i18n check` expects under an arrangement, and a control. <details><summary>Readings (branch cut from origin/main 815e882, origin/main merged at d830f5a; head d830f5a)</summary> - Premise, at 815e882, two throwaway probes (deleted): - `collectExpectedEntries` scaffolded `_relatedLists.crm_task` and `.crm_note` over lists the arrangement hid or named bare, and `validateTranslationReferences` refused both as `error`. It did not scaffold `.crm_call`, which the arrangement labelled and the rule accepts. - Real `translateMetaDocument` and `translateMetaList` served `['Notes', '任务']`: the arrangement's `Notes` was untranslated, though the pair ships `笔记`. `servedOverrideBaseOf('object', served)` returned `undefined`, and the pair bundle was asked 0 times. - Ablation through `scripts/ablation-replace.mjs` on the committed head, each restore `blob == HEAD` and `git diff HEAD` empty: - by-name arm `?? objectPairRelatedListsBundleOf(…)` removed: `meta-object-related-list-pair-i18n.test.ts` `Tests 3 failed | 2 passed (5)` (at 48c654c, before the sixth pin); - list arm removed: `3 failed | 2 passed (5)` (same); - slice replaced by the whole pair bundle: `1 failed` (the D10 scope pin); - at 7ddcc64, the `hasRelatedListTitleOffBase` gate removed: `1 failed | 5 passed (6)` (the statement-budget pin); - `foldRelatedListExtensions` removed from `pushRelatedListLabels`: `i18n-related-lists-arrangement-36595.test.ts` `2 failed | 9 passed (11)`; - the `layer === 'place'` skip removed: `1 failed | 10 passed (11)`. - The subjects resolve from `src/` (relative imports), so no build was needed. - Full package suites, under `os-verify-lock.sh`: - `@objectstack/lint`: `Test Files 243 passed (243)`, `Tests 9816 passed (9816)`; - `@objectstack/rest` at 7ddcc64: `Test Files 439 passed (439)`, `Tests 9288 passed | 376 skipped (9664)`; - `@objectstack/runtime` `src/mcp-list-objects-statements.pin.test.ts` at 7ddcc64: `Tests 20 passed (20)`. At fe0f53e it failed 1 of 20 (memo `list_objects` 31 statements at 150 objects against a bound of 24), and with the pair arm ablated it passed 20 of 20. That failure was this PR's, and 7ddcc64 fixes it; - `@objectstack/cli` `test/i18n-coverage.test.ts`: `Tests 32 passed (32)`. - `turbo build --force` of the lint, rest and objectql closures (dts included): 32/32. `typecheck` exit 0 for `@objectstack/lint`, `@objectstack/rest`, `@objectstack/spec` and `@objectstack/objectql`. `@objectstack/spec check:generated`: "All 14 generated artifacts are up to date". - `eslint` on the nine changed `.ts`: exit 0. `check-adr-0087-registration --base origin/main`: registered, `not-required (no-migration-prescription)`. - Derived local gate set, `dispatch-gates --ran` at fe0f53e: 129 derived, 127 run, all exit 0. 2 are NOT MEASURED: `check-plugin-teardown-shape --self-test` (its fixture commit is outside the shallow clone) and `check:dual-build-cjs-loads` (needs a full `pnpm build`). 7ddcc64 changes only `packages/rest/src/meta-item-read-gate.ts` and its new test. At 7ddcc64 these were re-run: the rest suite above, rest `tsc --noEmit` exit 0, `eslint` on the two files exit 0, and `check-engine-double-contract` exit 0. `fe0f53eb` added the new pin's `findOne` row to `scripts/engine-double-contract.pinned.json`; its absence was the engine-double-contract red at 48c654c. - Head d830f5a merges `origin/main` into 7ddcc64. The merge had no conflicts. `git diff 7ddcc64 d830f5a` over this PR's own files is empty, so the net diff is unchanged; the code readings above at 7ddcc64 stand for it. - CI on d830f5a: 70 check runs, 60 success, 10 skipped, 0 failed, 0 pending. `Lint UI` is skipped because the diff has no `ui/` path. </details> ## Acceptance notes - A label only a code extender's `place` entry gives is accepted by `translation-target-unknown` but not scaffolded by `os i18n extract`. This is deliberate, and it is the harmless direction: the registry does not apply a placement on a target with no `relatedLists` or on a list the owner already names, so asking for it could ask for a string no screen shows. Whether the rule should refuse those keys is a separate narrowing, not taken here. - The public form route (`form-routes.ts`) still translates its object with no pair bundle. A public form renders no record-page tabs, so the gap does not reach a screen; its comment stays true. - The pair's tab-title translations also outrank a tenant overlay's own tab label (a `sys_metadata` object row that relabels a tab). This is the ruled order of ruling record 6631250894: a pair translation, then the override's own text. - Skills: `skills/objectstack-i18n/SKILL.md` (the `_relatedLists` row) and `skills/objectstack-data/rules/relationships.md` (line 359) still say the remedy is to re-state the entry "with the owner's own `label`". That is still correct but no longer the only way, because the object read now translates any arrangement label through the pair. The follow-up is filed as #38128; see `Skills-docs:` above. - Dogfood battery (`(narrowing)` arm and `!` title), `pnpm --filter @objectstack/dogfood test` under `os-verify-lock` on the landing head d830f5a. It ran after `pnpm install --frozen-lockfile` and a build of the dogfood closure (`@objectstack/dogfood^...`, `@objectstack/cli`, `@objectstack/client-react`), because the merge brought in main's lockfile and version moves. Result: `VERDICT command-exit 0` (held the lock 2166s, shared-box seconds), `Test Files 490 passed | 3 skipped (493)`, `Tests 4144 passed | 68 skipped (4212)`. The same battery read the same counts at 7ddcc64 and at fe0f53e. ## Verification Read first (by risk): 1. `packages/rest/src/meta-item-read-gate.ts`: `objectPairRelatedListsBundleOf` and its two call sites. This is the served-read change: check that only the `_relatedLists` subtree is handed on. 2. `packages/lint/src/related-list-titles.ts`: the fold, lifted from the rule. Diff it against the removed block of `validate-translation-references.ts`. 3. `packages/lint/src/i18n-walk.ts`: `pushRelatedListLabels`, and which layer it skips. Two-minute check: `pnpm --filter @objectstack/rest exec vitest run src/meta-object-related-list-pair-i18n.test.ts` should show 6 passing. Delete the `?? (await objectPairRelatedListsBundleOf(…))` arm of the by-name read and the same command should show the by-name pins failing. ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: its generated artifacts are regenerated and committed. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L9qibw44Q7BwdAY1RmfR73 --- _Generated by [Claude Code](https://claude.ai/code/session_01L9qibw44Q7BwdAY1RmfR73)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 7605e0c commit ee2ffca

12 files changed

Lines changed: 691 additions & 129 deletions
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@objectstack/lint': patch
3+
'@objectstack/rest': patch
4+
'@objectstack/spec': patch
5+
---
6+
7+
fix(lint,rest)!: `os i18n extract` / `os i18n check` expect the `_relatedLists` keys `os validate` accepts under a `.custom` arrangement, and the object read translates a tab title the arrangement sets
8+
9+
Clause-②: yes (narrowing)
10+
Metadata-protocol: none
11+
12+
<!-- adr-0087: not-required (no-migration-prescription) no schema key, accepted value, stored shape or export moves; the moved answers are the coverage gate's expected key set and the translation an object read serves, and the remedy is a translation the author adds or drops in a bundle, which no conversion can write -->
13+
14+
**BREAKING** for a stack that runs `os i18n check --strict` (or `--threshold`) and carries a paired `.custom` package's `relatedLists` arrangement (ADR-0146 D10) that labels a record-page tab. The coverage gate now expects `objects.<object>._relatedLists.<list>.label` for each list the arrangement labels, with the arrangement's text, so a stack that passed in 19.0.0-next.1 without that translation now reports it missing. Add the translation, or drop the arrangement entry's `label`. Keys over a list the arrangement hides, names bare or re-states without a `label` are no longer expected, so a gate that demanded a key `os validate` refuses stops demanding it.
15+
16+
**What changes in `@objectstack/lint`.**
17+
18+
- `collectExpectedEntries`, which `os i18n extract` and `os i18n check` read, folds the owner's `relatedLists` with the stack's `objectExtensions` the way `translation-target-unknown` folds them: every placement first, then the arrangement, whose entries replace every entry they cover (`relatedListNameCovers`). It is one fold, `related-list-titles.ts`, read by both. `os i18n extract` scaffolds no key over a list the arrangement hides, names bare or re-states without a `label`, and scaffolds one, carrying the arrangement's text, over a list it labels. A label only a code extender's `place` entry gives is still not scaffolded: the rule accepts its key, but the registry may not apply the placement.
19+
- The two `translation-target-unknown` hints for such a key name the list it addresses, `{ list: 'LIST', label }`, instead of "the owner's `label`". The stripped label may be a placement's, and where a bare child name covers a dotted list, the entry to write is the dotted list's own.
20+
21+
**What changes in `@objectstack/rest`.** The `/meta/object` reads (by name and list) hand the translator the paired `.custom` package's own `objects.<object>._relatedLists` translations, read for the pair of the base the object's packaged base ships in. A tab title the arrangement sets or changes now reads the pair's translation, then keeps its own text. Before, it read nothing, because an object answers no `servedOverrideBaseOf` (ADR-0146 D10, unchanged). Only that subtree is handed on: every other string of an object keeps the ranking it had.
22+
23+
**What changes in `@objectstack/spec`.** The wording of the `translation-related-list-key-under-arrangement-refused` ledger entry: the label the arrangement strips may be a placement's, and the remedy no longer says that a translated title needs the owner's label.

‎content/docs/protocol/kernel/i18n-standard.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ beneath an action entry are judged the same way under either.
11741174
| `objects.{object}._views.{view}` | the key the view registry assigns a view over that object: a `listViews` / `formViews` map key, or the default `list`'s `name` — `default` when it has none (see [ObjectUI Integration](#objectui-integration)) |
11751175
| `objects.{object}._sections.{section}` | a `fieldGroups[].key`, a named section of a form view over that object (a `formViews` entry or the default `form`), or a named section of a `record:details` component on a page bound to it |
11761176
| `objects.{object}._tabs.{tab}` | a filter-preset tab's `name` in `interfaceConfig.userFilters.tabs` on a page over that object (`interfaceConfig.source`, else the page's `object`) — a list view's own `tabs` has no renderer and is not resolvable |
1177-
| `objects.{object}._relatedLists.{list}` | the `list` of an object-form `relatedLists` entry on that object that authors a `label` — a dotted `object.field` is one key; a key over an entry with no `label`, a bare-string entry or a built-in tab is an orphan, because that tab's title is the child lookup field's `relatedListTitle`, translated on the child. The paired `.custom` arrangement's `relatedLists` is applied after the owner's list and every placement: a list it hides, names bare or names without a `label` is an orphan whatever label the owner gave it, and a list it labels resolves |
1177+
| `objects.{object}._relatedLists.{list}` | the `list` of an object-form `relatedLists` entry on that object that authors a `label` — a dotted `object.field` is one key; a key over an entry with no `label`, a bare-string entry or a built-in tab is an orphan, because that tab's title is the child lookup field's `relatedListTitle`, translated on the child. The paired `.custom` arrangement's `relatedLists` is applied after the owner's list and every placement: a list it hides, names bare or names without a `label` is an orphan whatever label the owner or a placement gave it, and a list it labels resolves. `os i18n extract` and `os i18n check` expect exactly the keys over the owner's and the arrangement's labelled lists, and the object read translates a title the arrangement sets from the `.custom` package's own translations |
11781178
| `objects.{object}._validations.{rule}` | a validation rule's `name` in that object's `validations[]` or in an `objectExtensions[]` entry aimed at it — a `conditional` rule's `then` / `otherwise` branch included |
11791179
| `objects.{object}._milestones.{field}.{value}` | an `activityMilestones[]` entry of that object watching `field` and firing on `value` |
11801180
| `objects.{object}._actions.{action}` | an action bound to that object: one in its `actions`, or a stack-level action whose `objectName` is that object |

‎packages/cli/test/i18n-coverage.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,3 +518,36 @@ describe('computeI18nCoverage — the users\' defaultLocale stays gated beside s
518518
expect(report).toEqual(run(undeclared, [ES], { defaultLocale: 'zh-CN' }));
519519
});
520520
});
521+
522+
// [#37622] `os i18n check` reads its expected keys from `collectExpectedEntries`,
523+
// which folds the owner's tab list with the stack's `.custom` arrangement the
524+
// way `os validate` does: no key over a tab the arrangement hides, and one
525+
// over a tab it titles.
526+
describe('computeI18nCoverage — _relatedLists under a `.custom` arrangement (#37622)', () => {
527+
const arranged: any = {
528+
objects: [{
529+
name: 'account',
530+
label: 'Account',
531+
fields: { name: { label: 'Name' } },
532+
relatedLists: [{ list: 'contact', label: 'People' }, 'case'],
533+
}],
534+
objectExtensions: [{ extend: 'account', relatedLists: [{ list: 'contact', hidden: true }, { list: 'case', label: 'Tickets' }] }],
535+
translations: [{ en: { objects: { account: { label: 'Account' } } }, 'zh-CN': { objects: { account: { label: '客户' } } } }],
536+
};
537+
538+
it('expects the tab the arrangement titles and not the one it hides', () => {
539+
const zhKeys = new Set(
540+
computeI18nCoverage(arranged, { defaultLocale: 'en' }).issues
541+
.filter((i) => i.locale === 'zh-CN' && i.key.includes('._relatedLists.'))
542+
.map((i) => i.key),
543+
);
544+
expect([...zhKeys]).toEqual(['objects.account._relatedLists.case.label']);
545+
});
546+
547+
it('control: with no arrangement, the owner\'s labelled tab is expected', () => {
548+
const zhKeys = computeI18nCoverage({ ...arranged, objectExtensions: [] }, { defaultLocale: 'en' }).issues
549+
.filter((i) => i.locale === 'zh-CN' && i.key.includes('._relatedLists.'))
550+
.map((i) => i.key);
551+
expect(zhKeys).toEqual(['objects.account._relatedLists.contact.label']);
552+
});
553+
});

‎packages/lint/src/i18n-related-lists-arrangement-36595.test.ts‎

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import { describe, it, expect } from 'vitest';
1313
import { validateTranslationReferences, TRANSLATION_TARGET_UNKNOWN } from './validate-translation-references.js';
14+
import { collectExpectedEntries } from './i18n-walk.js';
1415

1516
const ACCOUNT = {
1617
name: 'account',
@@ -50,7 +51,7 @@ describe('validateTranslationReferences — _relatedLists under a `.custom` arra
5051
const findings = judge([{ extend: 'account', relatedLists: [restated] }], { contact: { label: '联系人' } });
5152
expect(findings.map((f) => f.path), JSON.stringify(restated)).toEqual([KEY('contact')]);
5253
expect(findings[0].message, JSON.stringify(restated)).toContain('carries no `label` in the `.custom` arrangement');
53-
expect(findings[0].hint, JSON.stringify(restated)).toContain("owner's `label`");
54+
expect(findings[0].hint, JSON.stringify(restated)).toContain("{ list: 'contact', label }");
5455
expect(findings[0].message.length).toBeLessThanOrEqual(200);
5556
expect(findings[0].hint.length).toBeLessThanOrEqual(200);
5657
}
@@ -75,9 +76,22 @@ describe('validateTranslationReferences — _relatedLists under a `.custom` arra
7576
expect(judge([{ extend: 'account', relatedLists: arrangement }], { 'event.related_to': { label: '会议' } }), JSON.stringify(arrangement))
7677
.toEqual([]);
7778
}
78-
// A sibling that would cancel a `hidden` entry is a list both shown and
79-
// hidden in one arrangement, which the object schema refuses at save
80-
// (`refuseContradictoryRelatedListEntries`), so it has no pin here.
79+
});
80+
81+
it('a dotted list one entry hides stays hidden beside the bare child a sibling entry names (#37622)', () => {
82+
// The object schema refuses a cancelling sibling only when both entries
83+
// name the SAME list (`refuseContradictoryRelatedListEntries`), so this
84+
// shape parses: the bare child drops the dotted list's label in the first
85+
// pass, and the hidden entry hides it in the second, in either order.
86+
for (const arrangement of [
87+
[{ list: 'event.related_to', hidden: true }, 'event'],
88+
['event', { list: 'event.related_to', hidden: true }],
89+
]) {
90+
const findings = judge([{ extend: 'account', relatedLists: arrangement }], { 'event.related_to': { label: '会议' } });
91+
expect(findings.map((f) => [f.severity, f.path]), JSON.stringify(arrangement)).toEqual([['error', KEY('event.related_to')]]);
92+
expect(findings[0].message, JSON.stringify(arrangement)).toContain('hidden');
93+
expect(findings[0].hint, JSON.stringify(arrangement)).toContain("{ list: 'event.related_to', label }");
94+
}
8195
});
8296

8397
it('applies the arrangement after every placement, whatever the extensions\' order', () => {
@@ -115,3 +129,55 @@ describe('validateTranslationReferences — _relatedLists under a `.custom` arra
115129
)).toEqual([]);
116130
});
117131
});
132+
133+
// [#37622] `os i18n extract` and `os i18n check` read the expected keys from
134+
// `collectExpectedEntries`, which folds the owner's tab list with the same
135+
// arrangement the rule above folds: every key the extractor scaffolds is one
136+
// `os validate` accepts, and a list the arrangement labels is scaffolded.
137+
describe('collectExpectedEntries — _relatedLists agree with the rule under a `.custom` arrangement (#37622)', () => {
138+
const expected = (objectExtensions: unknown[]) =>
139+
collectExpectedEntries({ objects: [ACCOUNT], objectExtensions } as never)
140+
.filter((entry) => entry.path[2] === '_relatedLists')
141+
.map((entry) => [entry.path[3], entry.sourceValue]);
142+
143+
/** The keys the extractor scaffolds, translated, judged by the rule. */
144+
const scaffoldedJudged = (objectExtensions: unknown[]) => {
145+
const keys = Object.fromEntries(expected(objectExtensions).map(([list]) => [list, { label: '译文' }]));
146+
return judge(objectExtensions, keys);
147+
};
148+
149+
const ARRANGEMENTS: Array<[string, unknown[]]> = [
150+
['none', []],
151+
['hides contact', [{ extend: 'account', relatedLists: [{ list: 'contact', hidden: true }] }]],
152+
['names contact bare', [{ extend: 'account', relatedLists: ['contact'] }]],
153+
['re-states contact with no label', [{ extend: 'account', relatedLists: [{ list: 'contact' }] }]],
154+
['relabels contact', [{ extend: 'account', relatedLists: [{ list: 'contact', label: 'Clients' }] }]],
155+
['labels a list the owner names bare', [{ extend: 'account', relatedLists: [{ list: 'case', label: 'Tickets' }] }]],
156+
['hides every event list through the bare child', [{ extend: 'account', relatedLists: [{ list: 'event', hidden: true }] }]],
157+
['labels the bare child', [{ extend: 'account', relatedLists: [{ list: 'event', label: 'Activity' }] }]],
158+
['keeps the dotted label beside the bare child', [{ extend: 'account', relatedLists: ['event', { list: 'event.related_to', label: 'Meetings' }] }]],
159+
];
160+
161+
it('every scaffolded key is accepted by `os validate`, for every arrangement', () => {
162+
for (const [name, objectExtensions] of ARRANGEMENTS) {
163+
expect(scaffoldedJudged(objectExtensions), name).toEqual([]);
164+
}
165+
});
166+
167+
it('scaffolds the tab titles the served object carries, with the text it serves', () => {
168+
expect(expected([])).toEqual([['contact', 'People'], ['event.related_to', 'Meetings']]);
169+
expect(expected(ARRANGEMENTS[1][1])).toEqual([['event.related_to', 'Meetings']]);
170+
expect(expected(ARRANGEMENTS[2][1])).toEqual([['event.related_to', 'Meetings']]);
171+
expect(expected(ARRANGEMENTS[4][1])).toEqual([['event.related_to', 'Meetings'], ['contact', 'Clients']]);
172+
expect(expected(ARRANGEMENTS[5][1])).toEqual([['contact', 'People'], ['event.related_to', 'Meetings'], ['case', 'Tickets']]);
173+
expect(expected(ARRANGEMENTS[6][1])).toEqual([['contact', 'People']]);
174+
expect(expected(ARRANGEMENTS[7][1])).toEqual([['contact', 'People'], ['event', 'Activity']]);
175+
expect(expected(ARRANGEMENTS[8][1])).toEqual([['contact', 'People'], ['event.related_to', 'Meetings']]);
176+
});
177+
178+
it('asks for no title a code extender\'s placement alone gives, which the rule still accepts', () => {
179+
const placed = [{ extend: 'account', place: [{ list: 'quote', after: 'contact', label: 'Quotes' }] }];
180+
expect(expected(placed)).toEqual([['contact', 'People'], ['event.related_to', 'Meetings']]);
181+
expect(judge(placed, { quote: { label: '报价' } })).toEqual([]);
182+
});
183+
});

‎packages/lint/src/i18n-walk.ts‎

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,12 @@
8787
* objects.<name>._validations.<rule>.message
8888
* objects.<name>._milestones.<field>.<value>.summary (an `activityMilestones`
8989
* entry's summary template)
90-
* objects.<name>._relatedLists.<list>.label (an object-form `relatedLists`
91-
* entry that authors a `label`)
90+
* objects.<name>._relatedLists.<list>.label (a record-page tab the served
91+
* object titles: an owner entry
92+
* that authors a `label`, as the
93+
* `.custom` arrangement leaves
94+
* it, or an arrangement entry
95+
* that authors one)
9296
* objects.<name>._actions.<action>.label
9397
* objects.<name>._actions.<action>.description
9498
* objects.<name>._actions.<action>.confirmText
@@ -202,6 +206,8 @@ import { APPROVAL_NODE_TYPE, flowDecisionEdgeBranch, isFlowTechnicalNodeType } f
202206
import { expandViewContainer, InlineLocaleMapSchema } from '@objectstack/spec/ui';
203207
import { authorWarnedProperties } from './lint-liveness-properties.js';
204208
import { walkPageComponents } from './page-walk.js';
209+
import { objectExtensionsByTarget } from './object-graph.js';
210+
import { addOwnerRelatedLists, emptyRelatedListTitles, foldRelatedListExtensions } from './related-list-titles.js';
205211

206212
// ─── Public types ──────────────────────────────────────────────────────
207213

@@ -1047,23 +1053,34 @@ function pushMilestoneSummaries(out: ExpectedEntry[], objectName: string, milest
10471053
}
10481054

10491055
/**
1050-
* Emit `objects.<object>._relatedLists.<list>.label` for every object-form
1051-
* `relatedLists` entry of an object that authors a `label` (the record page's
1052-
* tab title and table heading for that list, which wins over the child FK's
1053-
* `relatedListTitle`). The key is the entry's literal `list`, a dotted
1054-
* `object.field` included, indexed as is. Only an AUTHORED label is emitted:
1055-
* `translateObject` translates that label and swaps nothing in for an entry
1056-
* that has none, so a key for one would ask a translator for a string no
1057-
* screen shows.
1056+
* Emit `objects.<object>._relatedLists.<list>.label` for every record-page
1057+
* tab the SERVED object titles with a `label` (the tab title and table heading
1058+
* for that list, which wins over the child FK's `relatedListTitle`). The key
1059+
* is the entry's literal `list`, a dotted `object.field` included, indexed as
1060+
* is. Only an AUTHORED label is emitted: `translateObject` translates that
1061+
* label and swaps nothing in for an entry that has none, so a key for one
1062+
* would ask a translator for a string no screen shows.
1063+
*
1064+
* [#37622] The owner's entries are folded with the extensions of this stack
1065+
* that target the object ({@link foldRelatedListExtensions}, the fold the
1066+
* `translation-target-unknown` rule of `os validate` reads), so a list the
1067+
* paired `.custom` arrangement hides, names bare or re-states without a
1068+
* `label` gets no key, and a list the arrangement labels gets one, carrying
1069+
* the arrangement's text. A label only a code extender's `place` entry gives
1070+
* is not emitted: the rule accepts its key, but the registry may not apply the
1071+
* placement, so asking for it could ask for a string no screen shows.
10581072
*/
1059-
function pushRelatedListLabels(out: ExpectedEntry[], objectName: string, entries: unknown): void {
1060-
if (!Array.isArray(entries)) return;
1061-
for (const entry of entries) {
1062-
if (!entry || typeof entry !== 'object' || Array.isArray(entry)) continue;
1063-
const list = (entry as any).list;
1064-
if (typeof list !== 'string' || list.length === 0) continue;
1065-
const label = (entry as any).label;
1066-
if (typeof label !== 'string' || label.length === 0) continue;
1073+
function pushRelatedListLabels(
1074+
out: ExpectedEntry[],
1075+
objectName: string,
1076+
entries: unknown,
1077+
extensions: Parameters<typeof foldRelatedListExtensions>[1],
1078+
): void {
1079+
const titles = emptyRelatedListTitles();
1080+
addOwnerRelatedLists(titles, entries);
1081+
foldRelatedListExtensions(titles, extensions);
1082+
for (const [list, { label, layer }] of titles.labels) {
1083+
if (layer === 'place') continue;
10671084
pushEntry(out, ['objects', objectName, '_relatedLists', list, 'label'], label, 'object', { objectName });
10681085
}
10691086
}
@@ -1580,6 +1597,8 @@ export function collectExpectedEntries(
15801597

15811598
// ── Objects ───────────────────────────────────────────────────────
15821599
const objects: any[] = Array.isArray(config?.objects) ? config.objects : [];
1600+
// [#37622] The extensions each object's served tab list folds in, read once.
1601+
const extensionsByTarget = objectExtensionsByTarget(config);
15831602
for (const obj of objects) {
15841603
if (!obj?.name) continue;
15851604
const objectName = obj.name as string;
@@ -1710,11 +1729,12 @@ export function collectExpectedEntries(
17101729

17111730
// Record-page related-list titles (`_relatedLists.<list>.label`): the
17121731
// `label` an object-form `relatedLists` entry authors on this parent,
1713-
// keyed by the entry's literal `list` (`object.field` is one key).
1732+
// keyed by the entry's literal `list` (`object.field` is one key), after
1733+
// the paired `.custom` arrangement this stack carries is folded in.
17141734
// `translateObject` overlays only an authored label, so an entry without
17151735
// one — and a bare-string entry or built-in tab — gets no key: its title
17161736
// is the child FK's `relatedListTitle`, keyed on the child above.
1717-
pushRelatedListLabels(out, objectName, obj.relatedLists);
1737+
pushRelatedListLabels(out, objectName, obj.relatedLists, extensionsByTarget.get(objectName) ?? []);
17181738
}
17191739

17201740
// ── Top-level views ──────────────────────────────────────────────

0 commit comments

Comments
 (0)