Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .changeset/35021-approval-reject-wording.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
'@objectstack/plugin-approvals': patch
'@object-ui/i18n': patch
'@object-ui/app-shell': patch
---

fix(i18n): an approval rejection reads 驳回 in Chinese, on the runtime surfaces and in the designer's approval panel

Clause-②: no
Metadata-protocol: none

In Chinese, the approval runtime now names the reject decision 驳回 (zh-Hant 駁回), the word the flow designer gives the approval branch and the server notifications already use. Before, the designer's branch said 驳回 while its approval-node help and the approver's buttons said 拒绝 for the same decision.

- `@object-ui/i18n`: the `approvalsInbox` strings in zh-Hans and zh-Hant: the inbox and record-bar buttons, the bulk and single confirm dialogs, the toasts, the status chip (已拒绝 → 已驳回), the history row, the keyboard hint and the send-back limit notice.
- `@objectstack/plugin-approvals`: the zh-CN labels of `sys_approval_request` (the `approval_reject` lever, its confirm question and success toast, the `rejected` status) and of the `reject` row of `sys_approval_action`; the zh-Hant bundle already said 駁回. The email action-link confirm and result pages read 驳回.
- `@object-ui/app-shell`: the approval node's zh panel in the flow designer: the multi-approver help, the status-mirror help, the escalation help and its `auto_reject` option label (自动拒绝 → 自动驳回; the stored `auto_reject` value is unchanged), and the revision-limit help. Its branch label and Problems hint already said 驳回; a zh-Hant session draws the same Simplified table.

拒绝 stays where it means access denial or declining an invitation, in the AI tool approvals, and in the designer's end-node refused outcome and its API-key, bulk-update and audit-outcome refusals. Display text only: the stored `rejected` status and the `reject` action key are unchanged, and English and the other languages are untouched.
6 changes: 3 additions & 3 deletions packages/plugins/plugin-approvals/src/action-link-pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ export function renderConfirmPage(input: {
actPath: string;
}): string {
const approving = input.action === 'approve';
const verb = approving ? 'Approve · 通过' : 'Reject · 拒绝';
const verb = approving ? 'Approve · 通过' : 'Reject · 驳回';
return shell(`${verb} — Approval`, `
<h1>${approving ? '✅ Approve this request?' : '⛔ Reject this request?'}</h1>
<p class="sub">${approving ? '确认通过该审批请求?' : '确认拒绝该审批请求?'}
<p class="sub">${approving ? '确认通过该审批请求?' : '确认驳回该审批请求?'}
Acting as · 操作身份:<b>${esc(input.approverId)}</b></p>
${summaryRows(input.request)}
<form method="post" action="${esc(input.actPath)}" class="actions">
Expand All @@ -100,7 +100,7 @@ export function renderConfirmPage(input: {

const RESULT_COPY: Record<string, { cls: string; title: string; body: string }> = {
approved: { cls: 'ok', title: '✅ Approved · 已通过', body: 'The decision was recorded. · 审批结果已记录。' },
rejected: { cls: 'ok', title: '⛔ Rejected · 已拒绝', body: 'The decision was recorded. · 审批结果已记录。' },
rejected: { cls: 'ok', title: '⛔ Rejected · 已驳回', body: 'The decision was recorded. · 审批结果已记录。' },
invalid: { cls: 'err', title: 'Invalid link · 链接无效', body: 'This link is not recognized. · 无法识别该链接。' },
expired: { cls: 'warn', title: 'Link expired · 链接已过期', body: 'Ask the requester to send a new reminder. · 请让申请人重新发送催办。' },
consumed: { cls: 'warn', title: 'Already used · 链接已使用', body: 'This link was already used once. · 该链接已被使用过。' },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
//
// Approval-rejection wording pin (#35021, ruling 6973602227, option A).
//
// In Chinese an approval rejection reads 驳回 (zh-Hant 駁回): the record-page
// lever this plugin declares (`approval_reject`), its confirm question and
// success toast, the `rejected` status, the `reject` row of the action history,
// and the email action-link confirm and result pages. The flow designer's
// approval branch and the server notifications (`./translations/messages.ts`)
// already say it, so every surface names one decision with one word. The
// stored values (`rejected`, `reject`) are not display text and do not change.
//
// The labels are read through the real resolvers, so the cases also prove the
// bundles are REACHED: the declared labels are English, and 驳回 can only come
// from a bundle.

import { describe, it, expect } from 'vitest';
import { translateObject, translateMetadataDocument } from '@objectstack/spec/system';

import { ApprovalsTranslations } from './translations/index.js';
import { zhCNObjects } from './translations/zh-CN.objects.generated.js';
import { zhHantObjects } from './translations/zh-Hant.objects.generated.js';
import { SysApprovalRequest } from './sys-approval-request.object.js';
import { SysApprovalAction } from './sys-approval-action.object.js';
import { renderConfirmPage, renderResultPage } from './action-link-pages.js';

const LOCALES = [
{ locale: 'zh-CN', bundle: zhCNObjects, reject: '驳回', deny: '拒绝' },
{ locale: 'zh-Hant', bundle: zhHantObjects, reject: '駁回', deny: '拒絕' },
] as const;

const optionLabel = (object: unknown, field: string, value: string, locale: string): string | undefined => {
const doc = translateObject(object as any, ApprovalsTranslations, { locale });
const options = (doc as any)?.fields?.[field]?.options as Array<{ value: string; label?: string }> | undefined;
return options?.find((o) => o.value === value)?.label;
};

const servedAction = (locale: string, name: string): Record<string, unknown> | undefined => {
const doc = translateMetadataDocument('object', SysApprovalRequest, ApprovalsTranslations, { locale });
return ((doc as { actions?: Array<Record<string, unknown>> }).actions ?? []).find((a) => a.name === name);
};

/** Every string leaf of a bundle subtree, with its dotted path. */
const leaves = (node: unknown, path: string[] = []): Array<[string, string]> => {
if (typeof node === 'string') return [[path.join('.'), node]];
if (!node || typeof node !== 'object') return [];
return Object.entries(node).flatMap(([key, child]) => leaves(child, [...path, key]));
};

describe('approval rejection reads 驳回 (#35021)', () => {
describe.each(LOCALES)('$locale', ({ locale, bundle, reject, deny }) => {
it(`the reject lever, the rejected status and the reject history row read ${reject}`, () => {
expect(servedAction(locale, 'approval_reject')?.label).toBe(reject);
expect(optionLabel(SysApprovalRequest, 'status', 'rejected', locale)).toBe(`已${reject}`);
expect(optionLabel(SysApprovalAction, 'action', 'reject', locale)).toBe(reject);
});

it(`the reject lever's question and success toast say ${reject}`, () => {
const node = (bundle as any).sys_approval_request._actions.approval_reject;
expect(node.description).toContain(reject);
expect(node.successMessage).toContain(reject);
});

it(`no approval object string in the bundle says ${deny}`, () => {
const all = [
...leaves((bundle as any).sys_approval_request, ['sys_approval_request']),
...leaves((bundle as any).sys_approval_action, ['sys_approval_action']),
];
expect(all.length).toBeGreaterThan(0);
expect(all.filter(([, value]) => value.includes(deny))).toEqual([]);
});
});

it('the email action-link pages say 驳回 for the reject decision', () => {
const request = { id: 'req_1', record_id: 'rec_1', object_name: 'expense', process_name: 'p' } as any;
const confirm = renderConfirmPage({
request,
action: 'reject',
approverId: 'user_1',
token: 'tok',
actPath: '/act',
});
const result = renderResultPage('rejected', request);
expect(confirm).toContain('驳回');
expect(result).toContain('已驳回');
expect([confirm, result].filter((page) => page.includes('拒绝'))).toEqual([]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ describe('approval status vocabulary (#7232)', () => {
expect(resolvedStatusLabels('zh-CN')).toEqual({
pending: '待审批',
approved: '已批准',
rejected: '已拒绝',
// #35021: an approval rejection reads 驳回, the flow designer's word for
// the branch; 拒绝 is left to access denial and invitations.
rejected: '已驳回',
recalled: '已撤回',
returned: '已退回修改',
// #13568. 已作废, deliberately not 已取消: `recalled` is already 已撤回
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const zhCNObjects: NonNullable<TranslationData['objects']> = {
options: {
pending: "待审批",
approved: "已批准",
rejected: "已拒绝",
rejected: "已驳回",
recalled: "已撤回",
returned: "已退回修改",
cancelled: "已作废"
Expand Down Expand Up @@ -152,9 +152,9 @@ export const zhCNObjects: NonNullable<TranslationData['objects']> = {
}
},
approval_reject: {
label: "拒绝",
description: "拒绝该请求?拒绝对所有审批人立即生效。",
successMessage: "已拒绝“{{ result.request.record_title }}”",
label: "驳回",
description: "驳回该请求?驳回对所有审批人立即生效。",
successMessage: "已驳回“{{ result.request.record_title }}”",
params: {
comment: {
label: "审批意见"
Expand Down Expand Up @@ -280,7 +280,7 @@ export const zhCNObjects: NonNullable<TranslationData['objects']> = {
options: {
submit: "提交",
approve: "批准",
reject: "拒绝",
reject: "驳回",
recall: "撤回",
escalate: "升级",
reassign: "转签",
Expand Down
10 changes: 5 additions & 5 deletions ui/packages/app-shell/src/views/metadata-admin/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
},
behavior: {
label: '审批方式',
help: '多个审批人如何组合。任何一个拒绝在所有模式下都是否决。',
help: '多个审批人如何组合。任何一个驳回在所有模式下都是否决。',
opts: {
first_response: '首个响应生效',
unanimous: '全员通过',
Expand All @@ -484,7 +484,7 @@ const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
lockRecord: { label: '锁定记录', help: '此节点待处理期间锁定触发记录,禁止编辑。' },
approvalStatusField: {
label: '状态字段',
help: '将请求状态(待审 / 通过 / 拒绝)镜像到的业务对象字段。应为只读。',
help: '将请求状态(待审 / 通过 / 驳回)镜像到的业务对象字段。应为只读。',
},
'escalation.enabled': { label: 'SLA 升级', help: '在超时内未做决策时升级。' },
'escalation.timeoutHours': {
Expand All @@ -493,8 +493,8 @@ const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
},
'escalation.action': {
label: '超时动作',
help: '超过期限后怎么办:改派给其他人、自动通过、自动拒绝,或通知某人(默认)。',
opts: { notify: '通知', reassign: '改派', auto_approve: '自动通过', auto_reject: '自动拒绝' },
help: '超过期限后怎么办:改派给其他人、自动通过、自动驳回,或通知某人(默认)。',
opts: { notify: '通知', reassign: '改派', auto_approve: '自动通过', auto_reject: '自动驳回' },
},
'escalation.escalateTo': {
label: '升级至',
Expand All @@ -504,7 +504,7 @@ const FLOW_FIELD_ZH: Record<string, Record<string, FlowFieldZh>> = {
'escalation.notifySubmitter': { label: '通知提交人', help: '升级时通知提交请求的人。' },
maxRevisions: {
label: '最多退回次数',
help: '请求自动拒绝前的最多退回修订次数(0 表示禁用退回)。需要一条审批分支为「退回修改」的出边才生效。',
help: '请求自动驳回前的最多退回修订次数(0 表示禁用退回)。需要一条审批分支为「退回修改」的出边才生效。',
},
// objectstack#34818 — was English in the zh panel.
onEmptyApprovers: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.

/**
* objectstack#35021 — the approval node's zh panel names the reject decision
* 驳回, the word of its branch connection, of the runtime inbox and of the
* approval notifications (ruling 6973602227, option A; premise corrected
* 6975255638). The `auto_reject` value is stored metadata and stays.
*
* Every string the panel draws is enumerated, from the inspector's own field
* table and from the fields the engine serves (the contract's JSON Schema),
* and none may say 拒绝. A zh-Hant session draws the same Simplified table
* (`isZhLocale`), so it is held too. The end node's refused outcome is not an
* approval decision and keeps 已拒绝 — the control that the replacement did not
* reach past the approval node.
*/

import { describe, expect, it } from 'vitest';
import { z } from 'zod';
import { ApprovalNodeConfigSchema } from '@objectstack/spec/automation';
import { fieldsForNodeType, localizeFlowFields, type FlowConfigField } from './flow-node-config.js';
import { jsonSchemaToFlowFields } from './json-schema-to-fields.js';

/** Every visible string of a field, with where it sits. */
function strings(field: FlowConfigField): Array<[string, string]> {
const out: Array<[string, string]> = [[`${field.id}.label`, field.label]];
if (field.help) out.push([`${field.id}.help`, field.help]);
if (field.placeholder) out.push([`${field.id}.placeholder`, field.placeholder]);
for (const o of field.options ?? []) out.push([`${field.id}.opt.${o.value}`, o.label]);
for (const c of field.columns ?? []) {
out.push([`${field.id}.col.${c.key}.label`, c.label]);
if (c.help) out.push([`${field.id}.col.${c.key}.help`, c.help]);
for (const o of c.options ?? []) out.push([`${field.id}.col.${c.key}.opt.${o.value}`, o.label]);
}
return out;
}

const PANELS = [
['the inspector table', () => fieldsForNodeType('approval')],
['the served contract', () => jsonSchemaToFlowFields(z.toJSONSchema(ApprovalNodeConfigSchema, { io: 'input' }))!],
] as const;

describe('the approval node panel says 驳回 for the reject decision (objectstack#35021)', () => {
describe.each(['zh-CN', 'zh-Hant'])('%s', (locale) => {
it.each(PANELS)('no string of %s says 拒绝', (_name, fields) => {
const all = localizeFlowFields('approval', fields(), locale).flatMap(strings);
expect(all.length).toBeGreaterThan(0);
expect(all.filter(([, text]) => text.includes('拒绝'))).toEqual([]);
});

it('the reject-decision strings say 驳回, and the auto_reject value is unchanged', () => {
const byId = new Map(localizeFlowFields('approval', fieldsForNodeType('approval'), locale).map((f) => [f.id, f]));
for (const id of ['behavior', 'approvalStatusField', 'escalation.action', 'maxRevisions']) {
expect(byId.get(id)?.help, id).toContain('驳回');
}
const autoReject = byId.get('escalation.action')?.options?.find((o) => o.value === 'auto_reject');
expect(autoReject?.label).toBe('自动驳回');
});
});

it('control: the end node keeps 已拒绝 for its refused outcome', () => {
const outcome = localizeFlowFields('end', fieldsForNodeType('end'), 'zh-CN').find((f) => f.id === 'outcome');
expect(outcome?.options?.find((o) => o.value === 'refused')?.label).toBe('已拒绝');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* objectstack#35021 — an approval rejection reads 驳回 in Chinese, on the
* runtime surfaces as in the designer (ruling 6973602227, option A).
*
* The inbox, the record approval bar and the history timeline name the reject
* decision with the word the flow designer gives the approval branch, in
* zh-Hans and zh-Hant. 拒绝 keeps its own meanings: access denial, declining an
* invitation, and the AI tool approvals (`aiApprovals`), a different concept.
*
* What is pinned is the vocabulary, not the sentences: no `approvalsInbox`
* string in either Chinese pack says 拒绝, every key named for the reject
* decision says 驳回, and the runtime's decision word and status agree with the
* designer's branch and end-node labels. Each enumeration asserts it is
* non-empty first, so a family that stopped resolving cannot pass with
* nothing checked.
*/
import { describe, it, expect } from 'vitest';
import { builtInLocales } from '../locales';
import STUDIO_ZH from '../namespaces/studio/zh.js';

type Pack = Record<string, unknown>;

const group = (locale: 'zh-Hans' | 'zh-Hant', name: string): Pack =>
(builtInLocales[locale] as unknown as Record<string, Pack>)[name];

const strings = (pack: Pack): Array<[string, string]> =>
Object.entries(pack).filter((entry): entry is [string, string] => typeof entry[1] === 'string');

const SCRIPTS = [
{ locale: 'zh-Hans', reject: '驳回', deny: '拒绝' },
{ locale: 'zh-Hant', reject: '駁回', deny: '拒絕' },
] as const;

describe('approval rejection reads 驳回 on the runtime surfaces (objectstack#35021)', () => {
describe.each(SCRIPTS)('$locale', ({ locale, reject, deny }) => {
const inbox = group(locale, 'approvalsInbox');

it(`no approvalsInbox string says ${deny}`, () => {
const entries = strings(inbox);
expect(entries.length).toBeGreaterThan(0);
expect(entries.filter(([, value]) => value.includes(deny))).toEqual([]);
});

it(`every approvalsInbox key named for the reject decision says ${reject}`, () => {
const rejectKeys = strings(inbox).filter(([key]) => /reject/i.test(key));
expect(rejectKeys.length).toBeGreaterThan(0);
expect(rejectKeys.filter(([, value]) => !value.includes(reject))).toEqual([]);
});

it(`the decision verb reads ${reject} and the status reads 已${reject}`, () => {
expect(inbox.actReject).toBe(reject);
expect(inbox.reject).toBe(reject);
expect(inbox.statusRejected).toBe(`已${reject}`);
expect(inbox.rejectedToast).toBe(`已${reject}`);
});

it(`access denial, invitations and AI tool approvals keep ${deny}`, () => {
const aiApprovals = group(locale, 'aiApprovals');
expect(aiApprovals.reject).toBe(deny);
expect(aiApprovals.statusRejected).toBe(`已${deny}`);
const organization = group(locale, 'organization') as Record<string, Pack>;
expect((organization.invitations.status as Pack).rejected).toBe(`已${deny}`);
expect(organization.accept.decline).toBe(deny);
expect(String(group(locale, 'errors').forbidden)).toContain(deny);
});
});

it('the runtime decision word agrees with the designer branch and end node', () => {
const inbox = group('zh-Hans', 'approvalsInbox');
expect(inbox.actReject).toBe(STUDIO_ZH['engine.inspector.flowEdge.branchReject']);
expect(inbox.statusRejected).toBe(STUDIO_ZH['engine.flowCanvas.rejectedEnd']);
});
});
Loading
Loading