2929 * - the text is `II18nService.t(key, locale)`; a miss is the key echoed back,
3030 * and then the authored text stands.
3131 *
32- * [#35384] Except a METADATA label: the object's, the flow's and the
33- * position's. Each is resolved by the spec translator of its type
32+ * [#35384] Except a METADATA label: the object's, the flow's, the approval
33+ * step's and the position's. Each is resolved by the spec translator of its type
3434 * (`@objectstack/spec/system`) over every locale the service holds, with the
3535 * metadata route's `ResolveOptions` ({@link metaLabelTranslation}: the
3636 * reader's locale, the DECLARED fallback chain, and the authored language,
4444 * - the flow's by `translateFlow`, the translator the flow runner names a
4545 * flow by. `/meta` serves a flow document untranslated (`translateFlow` is
4646 * deliberately not in `translateMetadataDocument`'s table), so this is the
47- * spec's one reading of `flows.<flow>.label`.
47+ * spec's one reading of `flows.<flow>.label`;
48+ * - the approval step's by `resolveFlowApprovalStepLabel`, the spec's one
49+ * reading of `flows.<flow>.approvals.<node_id>.label`, over the flow's name
50+ * and the node's id the stored row carries (no flow document is read).
4851 *
4952 * So a reader in a deployment's declared `sourceLocale` reads these labels as
5053 * authored, never the `defaultLocale` row `t()` falls back to. `t()` carries
51- * the catalog sentences, and still the approval STEP's label: no spec
52- * translator reads `flows.<flow>.approvals.<node_id>.label` yet, and a second
53- * walk of the locale chain here would be a second resolver.
54+ * the catalog sentences only.
5455 *
5556 * objectql names a refused write's object this way (`objectDisplayLabel`,
5657 * through `objectLabelKey`), the REST door names a NOT NULL field this way
7071 * own `label` (`translation.zod.ts`, `positions`), which `translatePosition`
7172 * overlays on every served `position` document.
7273 *
73- * [#35384] Only the step's key is asked of `t()`. The flow and position keys
74- * are still spelled here, for the contract pin and for the readers that name
75- * them; `translateFlow` and `translatePosition` read the same addresses.
74+ * [#35384] No key is asked of `t()`. The flow, step and position keys are
75+ * still spelled here, for the contract pin and for the readers that name
76+ * them; `translateFlow`, `resolveFlowApprovalStepLabel` and
77+ * `translatePosition` read the same addresses.
7678 *
7779 * `<flow>` is the request's `process_name` without its `flow:` prefix, the
7880 * `Flow.name` the engine hands the node (`$flowName`), and `<node_id>` is its
100102import type { II18nService } from '@objectstack/spec/contracts' ;
101103import {
102104 resolveBundleLocale ,
105+ resolveFlowApprovalStepLabel ,
103106 translateFlow ,
104107 translateObject ,
105108 translatePosition ,
@@ -338,8 +341,6 @@ export function readerLabelsFor(
338341 seen . set ( key , value ) ;
339342 return value ;
340343 } ;
341- const picked = new Map < string , string | undefined > ( ) ;
342- const pick = ( key : string ) : string | undefined => memo ( picked , key , ( ) => render ( key ) ) ;
343344 // [#35384] Built on the first metadata label this read asks, once.
344345 let translation : { value : MetaLabelTranslation | undefined } | undefined ;
345346 /** One metadata label through its spec translator; `undefined` on any miss or throw. */
@@ -359,6 +360,12 @@ export function readerLabelsFor(
359360 const doc : FlowLike = { name : flowName } ;
360361 return translateFlow ( doc , bundle , options ) . label ;
361362 } ) ) ;
363+ // [#35384] The step's label, as the spec reads `flows.<flow>.approvals.<node_id>.label`;
364+ // no literal, so a miss picks nothing and the stored snapshot stands.
365+ const stepLabels = new Map < string , string | undefined > ( ) ;
366+ const stepLabel = ( flowName : string , nodeId : string ) : string | undefined =>
367+ memo ( stepLabels , approvalStepLabelKey ( flowName , nodeId ) , ( ) =>
368+ translated ( ( { bundle, options } ) => resolveFlowApprovalStepLabel ( bundle , flowName , nodeId , undefined , options ) ) ) ;
362369 const positionLabels = new Map < string , string | undefined > ( ) ;
363370 const positionLabel = ( positionName : string ) : string | undefined =>
364371 memo ( positionLabels , positionName , ( ) =>
@@ -377,7 +384,7 @@ export function readerLabelsFor(
377384 } ) ) ;
378385 return {
379386 flowLabel,
380- stepLabel : ( flowName , nodeId ) => pick ( approvalStepLabelKey ( flowName , nodeId ) ) ,
387+ stepLabel,
381388 objectLabel,
382389 positionLabel,
383390 sentence : ( key , params ) => render ( key , params ) ,
0 commit comments