diff --git a/.changeset/34060-record-lock-refusal-locale.md b/.changeset/34060-record-lock-refusal-locale.md new file mode 100644 index 00000000000..134855421f4 --- /dev/null +++ b/.changeset/34060-record-lock-refusal-locale.md @@ -0,0 +1,15 @@ +--- +'@objectstack/plugin-approvals': patch +'@objectstack/spec': patch +--- + +fix(plugin-approvals): the record-lock refusal is worded in the writer's locale + +Clause-②: no +Metadata-protocol: none + +A user who saved a record held by an approval in progress was refused `409 RECORD_LOCKED` with an English sentence in every locale, while the other refusals on the same request answered in the request locale. A zh-CN writer read `Project '华东仓储客服平台实施' is locked while an approval is in progress, and cannot be edited until that approval is complete`. + +The sentence is now rendered through the shared Operation Message Catalog (`@objectstack/spec/system`, `renderOperationMessage`), the catalog the record door's other refusals use. Four new keys cover what the lock hook has in hand: `record_locked` (object label and record title), `record_locked_untitled` (label only), `record_locked_unlabeled` (title only) and `record_locked_opaque` (neither). They ship in `en`, `zh-CN`, `ja-JP` and `es-ES`. The object is named by its label in the writer's locale (`objects..label` from the deployment's language pack, else the declared label), never by its API name. The same zh-CN writer now reads `项目「华东仓储客服平台实施」正在审批中,已被锁定,审批完成前无法编辑`. Batch rows (`updateMany`, `batch` upsert) carry the same sentence. + +Unchanged: the English sentence is byte-identical, a locale the catalog does not carry reads English, and the wire code `RECORD_LOCKED`, the 409 status and the `RECORD_LOCKED: ` message prefix do not move. A deployment can override each sentence under `errors.record_locked`, `errors.record_locked_untitled`, `errors.record_locked_unlabeled` and `errors.record_locked_opaque`. diff --git a/packages/plugins/plugin-approvals/src/approvals-plugin.ts b/packages/plugins/plugin-approvals/src/approvals-plugin.ts index 18c28579f47..e7d4d90c0ea 100644 --- a/packages/plugins/plugin-approvals/src/approvals-plugin.ts +++ b/packages/plugins/plugin-approvals/src/approvals-plugin.ts @@ -366,7 +366,9 @@ export class ApprovalsServicePlugin implements Plugin { unbindAllHooks(engine); // [#23618] The refusal's title is narrowed by the writer's served fields, // through the same lazily-resolved authority the snapshot redaction reads. - bindApprovalLockHook(engine, ctx.logger, fieldVisibility); + // …and it is worded in the writer's locale, with the object's label in + // that locale, through the same lazily-read `i18n` service. + bindApprovalLockHook(engine, ctx.logger, fieldVisibility, i18nService); bindRecordDeleteCancelHook(engine, this.service, ctx.logger); bindDelegationWriteGuard(engine, ctx.logger); // [#10749] Generic-door snapshot redaction. Registered here so the diff --git a/packages/plugins/plugin-approvals/src/lifecycle-hooks.ts b/packages/plugins/plugin-approvals/src/lifecycle-hooks.ts index 52f92d1b188..4278df5777a 100644 --- a/packages/plugins/plugin-approvals/src/lifecycle-hooks.ts +++ b/packages/plugins/plugin-approvals/src/lifecycle-hooks.ts @@ -131,7 +131,9 @@ import { withoutOperationPrivateKeys } from '@objectstack/core'; import { resolveDisplayField } from '@objectstack/spec/data'; +import { renderOperationMessage, type ValidationMessageTranslator } from '@objectstack/spec/system'; import { redactSnapshot, resolveReadableSnapshotFields, type FieldVisibilitySource } from './payload-redaction.js'; +import { readerLabelsFor, type ReaderLabelI18n } from './reader-locale-labels.js'; export const APPROVALS_HOOK_PACKAGE = 'plugin-approvals:lock'; @@ -273,7 +275,8 @@ function writerEnvelope(ctx: any): unknown { } /** - * The END-USER sentence for a record held by a live approval (#18153). + * The END-USER sentence for a record held by a live approval (#18153), in the + * WRITER's locale. * * Three degradations, in the order the material runs out, and none of them * reaches for the id or the object's API name: @@ -286,12 +289,64 @@ function writerEnvelope(ctx: any): unknown { * locked while an approval is in progress"), so a reader who has seen the old * text recognises the new one; what is added is the one thing the old sentence * never said — what has to happen before the record can be edited again. + * + * Rendered through the SHARED Operation Message Catalog + * (`@objectstack/spec/system`, the `record_locked*` keys), not a second + * mechanism: user-facing refusal text is in the request locale, and the record + * door's other refusals (`record_write_denied`, `record_access_denied`, this + * plugin's own `approval_recall_not_submitter`) already reach the user that + * way. Same `errors.` override address, same resolution ladder + * (deployment override → locale catalog → `en`), so a locale the catalog does + * not carry reads the English sentence. Which degradation applies picks the + * KEY; the label and the title are its parameters, never spliced into prose + * here, so each language orders and quotes them its own way. + */ +function recordLockRefusal( + objectLabel: string | undefined, + recordTitle: string | undefined, + locale: string | undefined, + translate: ValidationMessageTranslator | undefined, +): string { + const messageKey = recordTitle + ? (objectLabel ? 'record_locked' : 'record_locked_unlabeled') + : (objectLabel ? 'record_locked_untitled' : 'record_locked_opaque'); + const params: Record = {}; + if (objectLabel) params.object = objectLabel; + if (recordTitle) params.title = recordTitle; + return renderOperationMessage({ messageKey, params }, { locale, translate }); +} + +/** + * The writer's locale and the deployment lookups the refusal is worded with. + * + * The locale is `HookContext.session.locale`, the caller's language the engine + * copies onto every hook session so a hook refusal can answer in it (the + * request's `Accept-Language`, else the `localization` settings). The `i18n` + * service, resolved lazily per refusal because it is contributed by another + * plugin that may start after this one (ADR-0029 D8), supplies two things: + * the object's label in that locale (`objects..label`, negotiated by + * {@link readerLabelsFor}, the approvals door's one reader-locale label pick) + * and the deployment's `errors.` override. Absent, the built-in catalog + * still renders the writer's locale and the object keeps its declared label. */ -function recordLockRefusal(objectLabel: string | undefined, recordTitle: string | undefined): string { - const subject = recordTitle - ? (objectLabel ? `${objectLabel} '${recordTitle}'` : `'${recordTitle}'`) - : (objectLabel ? `This ${objectLabel}` : 'This record'); - return `${subject} is locked while an approval is in progress, and cannot be edited until that approval is complete`; +function refusalLocalization( + ctx: any, + i18nService: (() => ReaderLabelI18n | undefined) | undefined, +): { locale: string | undefined; service: ReaderLabelI18n | undefined; translate: ValidationMessageTranslator | undefined } { + const raw = ctx?.session?.locale; + const locale = typeof raw === 'string' && raw.length > 0 ? raw : undefined; + let service: ReaderLabelI18n | undefined; + try { + service = i18nService?.(); + } catch { + // i18n is optional and late-bound; a missing service degrades the wording, never the lock. + service = undefined; + } + const svc = service; + const translate: ValidationMessageTranslator | undefined = svc && typeof svc.t === 'function' + ? (key, loc, params) => svc.t(key, loc, params) + : undefined; + return { locale, service, translate }; } /** @@ -529,11 +584,17 @@ async function gatingRequests( * is narrowed by (#23618) — lazily, per refusal, because the security plugin may * start after this one. Absent, or resolving nothing, the title is served as * before, exactly as the payload snapshot is (`resolveReadableSnapshotFields`). + * + * `i18nService` resolves the deployment's `i18n` service the refusal is worded + * with in the writer's locale — the object's translated label and the + * `errors.record_locked*` override (see {@link refusalLocalization}). Absent, + * the sentence is still the catalog's, in the writer's locale. */ export function bindApprovalLockHook( engine: MinimalEngine, logger?: MinimalLogger, fieldVisibility?: () => FieldVisibilitySource | undefined, + i18nService?: () => ReaderLabelI18n | undefined, ): void { engine.registerHook('beforeUpdate', async (ctx: any) => { const object = (ctx?.object ?? ctx?.objectName) as string | undefined; @@ -602,9 +663,14 @@ export function bindApprovalLockHook( const recordId = String(pending?.record_id ?? ''); let schema: unknown; try { schema = engine.getSchema?.(object); } catch { /* registry unavailable — label degrades */ } - const objectLabel = typeof (schema as any)?.label === 'string' && (schema as any).label + const declaredLabel = typeof (schema as any)?.label === 'string' && (schema as any).label ? String((schema as any).label) : undefined; + // The sentence is in the writer's locale, and so is the label it names: + // the translated `objects..label` when the pack carries one, else + // the declared label. ⛔ Never the API name. + const { locale, service, translate } = refusalLocalization(ctx, i18nService); + const objectLabel = readerLabelsFor(service, locale)?.objectLabel(object) ?? declaredLabel; // `previous` is the pre-image the engine already read for THIS row; it is // used only when it really is the row this pending request names, so a // dispatch that ever carried a different row cannot title the wrong @@ -630,7 +696,7 @@ export function bindApprovalLockHook( `[approvals] update refused RECORD_LOCKED: record '${recordId}' of '${object}' ` + `is held by pending approval request '${String(pending?.id ?? '')}'`, ); - lockedError(recordLockRefusal(objectLabel, recordTitleOf(schema, asServed, recordId))); + lockedError(recordLockRefusal(objectLabel, recordTitleOf(schema, asServed, recordId), locale, translate)); } }, { packageId: APPROVALS_HOOK_PACKAGE, priority: 50 }); diff --git a/packages/plugins/plugin-approvals/src/record-lock-batch-row-status.integration.test.ts b/packages/plugins/plugin-approvals/src/record-lock-batch-row-status.integration.test.ts index 68d75b5b38c..3b82b1d7a78 100644 --- a/packages/plugins/plugin-approvals/src/record-lock-batch-row-status.integration.test.ts +++ b/packages/plugins/plugin-approvals/src/record-lock-batch-row-status.integration.test.ts @@ -50,6 +50,7 @@ import { SqlDriver } from '@objectstack/driver-sql'; import { ObjectStackProtocolImplementation } from '@objectstack/metadata-protocol'; import { resolveThrownHttpError } from '@objectstack/types'; import { bindApprovalLockHook } from './lifecycle-hooks.js'; +import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system'; import { installDefaultOrganization } from './default-organization.testkit.js'; const opportunity = { @@ -192,6 +193,37 @@ describe('[#8570] a locked record\'s batch row carries the 409 the hook declared expect((await engine.findOne('opportunity', { where: { id: freeId } }))?.amount).toBe(555); }); + // [#34060] The row carries the sentence in the WRITER's locale — the same + // sentence the by-id door answers (`record-lock-user-facing-message.test.ts`), + // because both are the one hook's one refusal. Only the sentence moves: the + // row's `code` and `httpStatus` are the ones pinned above, in every locale. + it('a zh-CN writer\'s row carries the Chinese sentence; an en-US writer\'s the English one', async () => { + const rowIn = async (locale: string) => { + const res: any = await protocol.updateManyData({ + object: 'opportunity', + records: [{ id: lockedId, data: { amount: 999 } }], + context: { userId: 'u_writer', positions: [], permissions: [], locale }, + }); + expect(res.results[0].success).toBe(false); + return res.results[0].errors[0]; + }; + const zh = BUILTIN_OPERATION_MESSAGES['zh-CN'].record_locked + .replace('{{object}}', 'Opportunity').replace('{{title}}', 'Deal'); + expect(await rowIn('zh-CN')).toEqual({ code: 'RECORD_LOCKED', message: `RECORD_LOCKED: ${zh}`, httpStatus: 409 }); + expect(await rowIn('en-US')).toEqual({ + code: 'RECORD_LOCKED', + message: "RECORD_LOCKED: Opportunity 'Deal' is locked while an approval is in progress, and cannot be edited until that approval is complete", + httpStatus: 409, + }); + const upsert: any = await protocol.batchData({ + object: 'opportunity', + request: { operation: 'upsert', records: [{ id: lockedId, data: { amount: 999 } }] }, + context: { userId: 'u_writer', positions: [], permissions: [], locale: 'zh-CN' }, + }); + expect(upsert.results[0].errors[0]).toEqual({ code: 'RECORD_LOCKED', message: `RECORD_LOCKED: ${zh}`, httpStatus: 409 }); + expect((await engine.findOne('opportunity', { where: { id: lockedId } }))?.amount).toBe(100); + }); + it('the batchData upsert loop answers the same way — not just updateManyData', async () => { const res: any = await protocol.batchData({ object: 'opportunity', diff --git a/packages/plugins/plugin-approvals/src/record-lock-user-facing-message.test.ts b/packages/plugins/plugin-approvals/src/record-lock-user-facing-message.test.ts index 8a6bc2bb900..ad98340f32c 100644 --- a/packages/plugins/plugin-approvals/src/record-lock-user-facing-message.test.ts +++ b/packages/plugins/plugin-approvals/src/record-lock-user-facing-message.test.ts @@ -43,6 +43,7 @@ import { describe, it, expect, beforeEach, afterEach } from 'vitest'; import { ObjectQL } from '@objectstack/objectql'; import { SqlDriver } from '@objectstack/driver-sql'; import { bindApprovalLockHook, APPROVALS_HOOK_PACKAGE } from './lifecycle-hooks.js'; +import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system'; import { installDefaultOrganization } from './default-organization.testkit.js'; const OPPORTUNITY = { @@ -265,3 +266,151 @@ describe('[#18153] CONTROL — the operator-facing refusals are untouched', () = expect(thrown.statusCode).toBe(409); }); }); + +/** + * [#34060] The per-row refusal is in the WRITER's locale. + * + * User-facing refusal text is in the request locale (ruling C on #32440), and + * the record door's other refusals already answer that way through the shared + * Operation Message Catalog. This refusal now does too, under the + * `record_locked*` keys: the object is named by its label in the writer's + * locale (the pack's `objects..label`, else the declared label), the + * record by its title, and a locale the catalog does not carry reads English. + * The wire vocabulary does not move: `RECORD_LOCKED` / 409 and the + * `CODE: message` envelope on every leg. + * + * Same real rig as the #18153 describe above. The `i18n` service is a double + * holding one zh-CN pack, shaped as `II18nService` answers: `t()` echoes the + * key back on a miss, and `getLocales()` lists what it holds. + */ +describe('[#34060] the per-row refusal is worded in the writer\'s locale', () => { + const TAIL_EN = 'is locked while an approval is in progress, and cannot be edited until that approval is complete'; + const ZH = BUILTIN_OPERATION_MESSAGES['zh-CN']; + const PACKS: Record> = { + 'zh-CN': { + 'objects.opportunity.label': '商机', + 'objects.ledger_entry.label': '分类账分录', + }, + }; + const i18n = { + getLocales: () => Object.keys(PACKS), + t: (key: string, locale: string) => PACKS[locale]?.[key] ?? key, + }; + + let engine: ObjectQL; + let opportunityId: string; + let ledgerId: string; + + afterEach(async () => { + try { await engine?.destroy(); } catch { /* noop */ } + }); + + async function rig(service: (() => any) | undefined): Promise { + engine = new ObjectQL(); + engine.registerDriver(new SqlDriver({ + client: 'better-sqlite3', + connection: { filename: ':memory:' }, + useNullAsDefault: true, + }), true); + await engine.init(); + for (const o of [OPPORTUNITY, LEDGER_ENTRY, APPROVAL_REQUEST]) { + engine.registry.registerObject(o as any, 'com.objectstack.test.34060'); + } + await engine.syncSchemas(); + await installDefaultOrganization(engine); + opportunityId = String((await engine.insert('opportunity', { name: 'Acme renewal', amount: 100 })).id); + ledgerId = String((await engine.insert('ledger_entry', { amount: 100 })).id); + for (const [object, recordId] of [['opportunity', opportunityId], ['ledger_entry', ledgerId]] as const) { + await engine.insert('sys_approval_request', { + object_name: object, record_id: recordId, status: 'pending', + flow_run_id: 'run_1', node_config_json: NODE_CONFIG, + }, { context: { isSystem: true } } as any); + } + bindApprovalLockHook(engine as any, undefined, undefined, service); + } + + /** The refusal a writer in `locale` gets; the engine copies the envelope's locale onto the hook session. */ + async function refusalIn(locale: string | undefined, object: string, id: string): Promise { + let thrown: any = null; + try { + await engine.update(object, { amount: 999 }, { + where: { id }, + context: { userId: 'u_writer', positions: [], permissions: [], ...(locale ? { locale } : {}) }, + } as any); + } catch (e) { thrown = e; } + expect(thrown).not.toBeNull(); + expect(thrown.code).toBe('RECORD_LOCKED'); + expect(thrown.statusCode).toBe(409); + expect(thrown.message.startsWith('RECORD_LOCKED: ')).toBe(true); + // Nothing reached the store. + expect((await engine.findOne(object, { where: { id } }))?.amount).toBe(100); + return thrown; + } + + it('zh-CN: the Chinese sentence, naming the object by its zh-CN label and the record by its title', async () => { + await rig(() => i18n); + const thrown = await refusalIn('zh-CN', 'opportunity', opportunityId); + expect(thrown.message).toBe( + `RECORD_LOCKED: ${ZH.record_locked.replace('{{object}}', '商机').replace('{{title}}', 'Acme renewal')}`, + ); + expect(thrown.message).toContain('商机「Acme renewal」'); + expect(thrown.message).not.toContain(TAIL_EN); + expect(thrown.message).not.toContain(opportunityId); + }); + + it('zh-CN, a record with no title: the label-only sentence, still in Chinese', async () => { + await rig(() => i18n); + const thrown = await refusalIn('zh-CN', 'ledger_entry', ledgerId); + expect(thrown.message).toBe(`RECORD_LOCKED: ${ZH.record_locked_untitled.replace('{{object}}', '分类账分录')}`); + expect(thrown.message).not.toContain(ledgerId); + }); + + it('a bare `zh` reaches the zh-CN sentence and label', async () => { + await rig(() => i18n); + const thrown = await refusalIn('zh', 'opportunity', opportunityId); + expect(thrown.message).toContain('商机「Acme renewal」'); + }); + + it('en-US: the English sentence, byte-identical to the one this replaced', async () => { + await rig(() => i18n); + const thrown = await refusalIn('en-US', 'opportunity', opportunityId); + expect(thrown.message).toBe(`RECORD_LOCKED: Opportunity 'Acme renewal' ${TAIL_EN}`); + }); + + it('a locale the catalog does not carry falls back to English', async () => { + await rig(() => i18n); + const thrown = await refusalIn('xx-YY', 'opportunity', opportunityId); + expect(thrown.message).toBe(`RECORD_LOCKED: Opportunity 'Acme renewal' ${TAIL_EN}`); + }); + + it('no locale on the write: English', async () => { + await rig(() => i18n); + const thrown = await refusalIn(undefined, 'opportunity', opportunityId); + expect(thrown.message).toBe(`RECORD_LOCKED: Opportunity 'Acme renewal' ${TAIL_EN}`); + }); + + it('no i18n service: the built-in catalog still answers zh-CN, with the declared label', async () => { + await rig(undefined); + const thrown = await refusalIn('zh-CN', 'opportunity', opportunityId); + expect(thrown.message).toBe( + `RECORD_LOCKED: ${ZH.record_locked.replace('{{object}}', 'Opportunity').replace('{{title}}', 'Acme renewal')}`, + ); + }); + + it('a deployment translation of `errors.record_locked` wins, interpolated', async () => { + const override = { + getLocales: () => ['zh-CN'], + t: (key: string, locale: string) => + key === 'errors.record_locked' && locale === 'zh-CN' ? '{{object}}《{{title}}》审批中,暂不可改' : i18n.t(key, locale), + }; + await rig(() => override); + const thrown = await refusalIn('zh-CN', 'opportunity', opportunityId); + expect(thrown.message).toBe('RECORD_LOCKED: 商机《Acme renewal》审批中,暂不可改'); + }); + + it('a throwing i18n service degrades the wording, never the lock', async () => { + await rig(() => { throw new Error('i18n exploded'); }); + const thrown = await refusalIn('zh-CN', 'opportunity', opportunityId); + expect(thrown.message).toContain('Opportunity「Acme renewal」'); + }); +}); diff --git a/packages/spec/src/system/operation-message.test.ts b/packages/spec/src/system/operation-message.test.ts index 049625165b0..10fa3a34212 100644 --- a/packages/spec/src/system/operation-message.test.ts +++ b/packages/spec/src/system/operation-message.test.ts @@ -606,3 +606,48 @@ describe('operation message catalog — the master-detail write refusal', () => } }); }); + +/** + * plugin-approvals' record-lock refusal (`409 RECORD_LOCKED`): one wire code, + * four sentences, chosen by whether the hook holds the object's label and the + * record's title. The emitter is pinned against a real engine in + * `packages/plugins/plugin-approvals/src/record-lock-user-facing-message.test.ts`. + */ +describe('operation message catalog — the record-lock refusal', () => { + const KEYS = { + record_locked: ['{{object}}', '{{title}}'], + record_locked_untitled: ['{{object}}'], + record_locked_unlabeled: ['{{title}}'], + record_locked_opaque: [], + } as const; + + it('every locale defines all four, each with exactly its own placeholders', () => { + const locales = Object.keys(BUILTIN_OPERATION_MESSAGES); + expect(locales.length).toBeGreaterThanOrEqual(4); + for (const [locale, catalog] of Object.entries(BUILTIN_OPERATION_MESSAGES)) { + for (const [key, placeholders] of Object.entries(KEYS)) { + expect(catalog[key], `${locale} defines ${key}`).toBeTypeOf('string'); + expect(catalog[key].match(/\{\{\w+\}\}/g) ?? [], `${locale}.${key}`).toEqual([...placeholders]); + } + } + }); + + it('the English sentences keep the wording the hook answered before it was localized', () => { + const tail = 'is locked while an approval is in progress, and cannot be edited until that approval is complete'; + expect(renderOperationMessage({ messageKey: 'record_locked', params: { object: 'Opportunity', title: 'Acme renewal' } }, { locale: 'en' })) + .toBe(`Opportunity 'Acme renewal' ${tail}`); + expect(renderOperationMessage({ messageKey: 'record_locked_untitled', params: { object: 'Opportunity' } }, { locale: 'en' })) + .toBe(`This Opportunity ${tail}`); + expect(renderOperationMessage({ messageKey: 'record_locked_unlabeled', params: { title: 'Acme renewal' } }, { locale: 'en' })) + .toBe(`'Acme renewal' ${tail}`); + expect(renderOperationMessage({ messageKey: 'record_locked_opaque' }, { locale: 'en' })).toBe(`This record ${tail}`); + }); + + it('renders the caller locale, and falls back to en for a locale the catalog does not carry', () => { + const zh = renderOperationMessage({ messageKey: 'record_locked', params: { object: '项目', title: '华东仓储客服平台实施' } }, { locale: 'zh-CN' }); + expect(zh).toContain('项目「华东仓储客服平台实施」'); + expect(zh).toBe(BUILTIN_OPERATION_MESSAGES['zh-CN'].record_locked.replace('{{object}}', '项目').replace('{{title}}', '华东仓储客服平台实施')); + expect(renderOperationMessage({ messageKey: 'record_locked_opaque' }, { locale: 'de-DE' })) + .toBe(BUILTIN_OPERATION_MESSAGES.en.record_locked_opaque); + }); +}); diff --git a/packages/spec/src/system/operation-message.ts b/packages/spec/src/system/operation-message.ts index b89ca9f78a7..e433bf45e84 100644 --- a/packages/spec/src/system/operation-message.ts +++ b/packages/spec/src/system/operation-message.ts @@ -40,6 +40,7 @@ * | `record_queue_assign_denied` | they tried to create a record in a queue they do not belong to | leave the queue blank or choose one they belong to, or ask an administrator | * | `master_record_edit_denied` / `master_record_read_denied` (and their `_opaque` forms) | they wrote a `controlled_by_parent` record (a detail) without the edit access (or, where the detail asks it, the read access) its master record requires | ask the master record's owner, or an administrator | * | `field_edit_denied` / `field_edit_denied_opaque` | they changed a field their permissions do not let them edit | undo that change, or ask an administrator | + * | `record_locked` (and its `_untitled`, `_unlabeled` and `_opaque` forms) | they tried to change a record an approval in progress holds | wait until that approval is complete | * * `record_write_denied` (commit aa5994e17) is NOT `record_access_denied` restated: the * sharing middleware's by-id write gate fires on a row the READ path already @@ -270,7 +271,23 @@ export function operationMessageTranslationKey(messageKey: string): string { * * The English sentences are byte-identical to the fixed text the HTTP doors * answered before they were localized, so an English deployment reads no - * change for a single field or none. + * change for a single field or none. * + * The four `record_locked*` keys are the end user's sentence of plugin-approvals' + * per-row record lock (`409 RECORD_LOCKED`, the refusal a user reads in a toast + * when they save a record a live approval holds). One wire code, four + * sentences, chosen by what the refusing hook has in hand, and none of them + * names the record id or the object's API name: + * + * - `record_locked` takes `{{object}}` (the object's LABEL in the caller's + * locale) and `{{title}}` (the record's title as served to the writer); + * - `record_locked_untitled` takes `{{object}}` alone, for a record with no + * title the writer may be served; + * - `record_locked_unlabeled` takes `{{title}}` alone, for an object with no + * label; + * - `record_locked_opaque` names nothing. + * + * Their English is byte-identical to the fixed sentence the hook answered + * before it was localized. */ export const BUILTIN_OPERATION_MESSAGES: Record> = { en: { @@ -319,6 +336,14 @@ export const BUILTIN_OPERATION_MESSAGES: Record> duplicate_record: 'A record with this value already exists', duplicate_record_field: 'A record with this {{field}} already exists', duplicate_record_fields: 'A record with the same {{fields}} already exists', + record_locked: + "{{object}} '{{title}}' is locked while an approval is in progress, and cannot be edited until that approval is complete", + record_locked_unlabeled: + "'{{title}}' is locked while an approval is in progress, and cannot be edited until that approval is complete", + record_locked_untitled: + 'This {{object}} is locked while an approval is in progress, and cannot be edited until that approval is complete', + record_locked_opaque: + 'This record is locked while an approval is in progress, and cannot be edited until that approval is complete', }, 'zh-CN': { permission_denied: '您没有执行此操作的权限,如需访问请联系管理员。', @@ -350,6 +375,10 @@ export const BUILTIN_OPERATION_MESSAGES: Record> duplicate_record: '已存在相同值的记录', duplicate_record_field: '已存在相同{{field}}的记录', duplicate_record_fields: '已存在{{fields}}均相同的记录', + record_locked: '{{object}}「{{title}}」正在审批中,已被锁定,审批完成前无法编辑', + record_locked_unlabeled: '「{{title}}」正在审批中,已被锁定,审批完成前无法编辑', + record_locked_untitled: '该{{object}}正在审批中,已被锁定,审批完成前无法编辑', + record_locked_opaque: '该记录正在审批中,已被锁定,审批完成前无法编辑', }, 'ja-JP': { permission_denied: 'この操作を実行する権限がありません。アクセスが必要な場合は管理者にお問い合わせください。', @@ -396,6 +425,10 @@ export const BUILTIN_OPERATION_MESSAGES: Record> duplicate_record: '同じ値のレコードがすでに存在します', duplicate_record_field: '同じ{{field}}のレコードがすでに存在します', duplicate_record_fields: '{{fields}}がすべて同じレコードがすでに存在します', + record_locked: '{{object}}「{{title}}」は承認処理中のためロックされています。承認が完了するまで編集できません', + record_locked_unlabeled: '「{{title}}」は承認処理中のためロックされています。承認が完了するまで編集できません', + record_locked_untitled: 'この{{object}}は承認処理中のためロックされています。承認が完了するまで編集できません', + record_locked_opaque: 'このレコードは承認処理中のためロックされています。承認が完了するまで編集できません', }, 'es-ES': { permission_denied: @@ -443,6 +476,14 @@ export const BUILTIN_OPERATION_MESSAGES: Record> duplicate_record: 'Ya existe un registro con este valor', duplicate_record_field: 'Ya existe un registro con el mismo valor de {{field}}', duplicate_record_fields: 'Ya existe un registro con los mismos valores de {{fields}}', + record_locked: + 'El registro de {{object}} «{{title}}» está bloqueado mientras hay una aprobación en curso y no se puede editar hasta que esa aprobación finalice', + record_locked_unlabeled: + 'El registro «{{title}}» está bloqueado mientras hay una aprobación en curso y no se puede editar hasta que esa aprobación finalice', + record_locked_untitled: + 'Este registro de {{object}} está bloqueado mientras hay una aprobación en curso y no se puede editar hasta que esa aprobación finalice', + record_locked_opaque: + 'Este registro está bloqueado mientras hay una aprobación en curso y no se puede editar hasta que esa aprobación finalice', }, };