@@ -3677,18 +3677,26 @@ export async function patchTranslationBundlesOf(
36773677 * `objects.<name>._relatedLists` subtree is handed on, per locale: every other
36783678 * string of the object keeps the ranking it has without a pair (D10), and an
36793679 * empty answer is `undefined`, never a catalog that answers nothing.
3680+ *
3681+ * The pair is asked only when `served` carries a tab title that diverges from
3682+ * the packaged base ({@link hasRelatedListTitleOffBase}), the one case its
3683+ * catalog decides: a title equal to the base's reads the deployment catalog,
3684+ * which already holds the pair's share. So an object list whose tab titles no
3685+ * arrangement changed pays no translation read (ADR-0090 D10's statement
3686+ * budget, `mcp-list-objects-statements.pin.test.ts` in `@objectstack/runtime`).
36803687 */
36813688async function objectPairRelatedListsBundleOf (
36823689 protocol : unknown ,
36833690 type : string ,
3684- name : unknown ,
3691+ served : unknown ,
36853692 packagedBase : unknown ,
36863693 memo ?: Map < string , Promise < unknown > > ,
36873694) : Promise < unknown > {
3695+ const name = ( served as Record < string , unknown > | null | undefined ) ?. name ;
36883696 if ( type !== 'object' || typeof name !== 'string' || name === '' ) return undefined ;
3689- const base = packagedBase && typeof packagedBase === 'object'
3690- ? ( packagedBase as Record < string , unknown > ) . _packageId
3691- : undefined ;
3697+ if ( ! packagedBase || typeof packagedBase !== 'object' ) return undefined ;
3698+ if ( ! hasRelatedListTitleOffBase ( served , packagedBase as Record < string , unknown > ) ) return undefined ;
3699+ const base = ( packagedBase as Record < string , unknown > ) . _packageId ;
36923700 const pair = await pairTranslationBundleOfBase ( protocol , base , memo ) ;
36933701 if ( ! pair || typeof pair !== 'object' ) return undefined ;
36943702 const slice : Record < string , unknown > = { } ;
@@ -3700,6 +3708,29 @@ async function objectPairRelatedListsBundleOf(
37003708 return Object . keys ( slice ) . length > 0 ? slice : undefined ;
37013709}
37023710
3711+ /**
3712+ * Whether `served` carries an object-form `relatedLists` entry whose non-empty
3713+ * `label` the packaged base's entry for the same `list` does not carry — the
3714+ * divergence `translateObjectRelatedLists` (`@objectstack/spec/system`) judges
3715+ * a title by, where an entry the base does not name counts as diverged.
3716+ */
3717+ function hasRelatedListTitleOffBase ( served : unknown , packagedBase : Record < string , unknown > ) : boolean {
3718+ const lists = ( served as Record < string , unknown > | null | undefined ) ?. relatedLists ;
3719+ if ( ! Array . isArray ( lists ) ) return false ;
3720+ const baseLabels = new Map < string , unknown > ( ) ;
3721+ for ( const raw of Array . isArray ( packagedBase . relatedLists ) ? packagedBase . relatedLists : [ ] ) {
3722+ if ( raw && typeof raw === 'object' && typeof ( raw as any ) . list === 'string' && ! baseLabels . has ( ( raw as any ) . list ) ) {
3723+ baseLabels . set ( ( raw as any ) . list , ( raw as any ) . label ) ;
3724+ }
3725+ }
3726+ return lists . some ( ( raw ) => {
3727+ if ( ! raw || typeof raw !== 'object' ) return false ;
3728+ const { list, label } = raw as Record < string , unknown > ;
3729+ return typeof list === 'string' && list !== '' && typeof label === 'string' && label !== ''
3730+ && baseLabels . get ( list ) !== label ;
3731+ } ) ;
3732+ }
3733+
37033734/** A non-empty string, or `undefined`. */
37043735function nonEmptyText ( value : unknown ) : string | undefined {
37053736 return typeof value === 'string' && value . length > 0 ? value : undefined ;
@@ -3883,7 +3914,7 @@ export async function translateMetaList(
38833914 const pairBundle = p === undefined
38843915 ? undefined
38853916 : ( await pairTranslationBundleOf ( p , metaType , item , pairBundles ) )
3886- ?? ( await objectPairRelatedListsBundleOf ( p , metaType , item ?. name , packagedBase , pairBundles ) ) ;
3917+ ?? ( await objectPairRelatedListsBundleOf ( p , metaType , item , packagedBase , pairBundles ) ) ;
38873918 const patchBundles = p === undefined ? undefined : await patchTranslationBundlesOf ( p , metaType , item ?. name , packageBundles ) ;
38883919 const out = translateMetadataDocument ( metaType , item , bundle , {
38893920 ...metaTranslateOptions ( i18n , locale ) ,
@@ -3963,7 +3994,7 @@ export async function translateMetaDocument(
39633994 const pairBundle = p === undefined
39643995 ? undefined
39653996 : ( await pairTranslationBundleOf ( p , metaType , document ) )
3966- ?? ( await objectPairRelatedListsBundleOf ( p , metaType , ( document as any ) ?. name , packagedBase ) ) ;
3997+ ?? ( await objectPairRelatedListsBundleOf ( p , metaType , document , packagedBase ) ) ;
39673998 // [#33952] Each patching package's own translations: a patched field slot's second rank.
39683999 const patchBundles = p === undefined ? undefined : await patchTranslationBundlesOf ( p , metaType , ( document as any ) ?. name ) ;
39694000 const translated = translateMetadataDocument ( metaType , document as any , bundle , {
0 commit comments