Skip to content

Commit 148010a

Browse files
committed
fix(app-shell): the zh dashboard panel hints follow the platform's business wording
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzh1FMUQYf1PcEunaaK
1 parent 78fd39c commit 148010a

2 files changed

Lines changed: 52 additions & 33 deletions

File tree

‎ui/packages/app-shell/src/views/metadata-admin/metadata-form-i18n.test.ts‎

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ describe('localizeMetadataForm — the spec form, in the author’s language', (
9191
'dashboard',
9292
'zh-CN',
9393
);
94-
expect(fieldByName(zh, 'columns')).toMatchObject({ label: '列数', helpText: '栅格列数(默认 12)' });
94+
expect(fieldByName(zh, 'columns')).toMatchObject({
95+
label: '列数',
96+
helpText: '组件排布所用的列数,1 到 24。留空时仪表盘会按组件的宽度自动选择。',
97+
});
9598
expect(fieldByName(zh, 'refreshIntervalSeconds')?.label).toBe('自动刷新');
9699
expect(fieldByName(zh, 'header')?.label).toBe('页眉');
97100
});
@@ -105,31 +108,46 @@ describe('localizeMetadataForm — the spec form, in the author’s language', (
105108
const gap = fieldByName(zh, 'gap');
106109
expect(gap?.label).toBe('间距');
107110

108-
// ⚠️ THE CONTROL IS NOT A SENTENCE PIN, and it used to be one. This asserted
109-
// that the English producer copy still said "Tailwind" — true while the spec
110-
// shipped `Grid gap (Tailwind units)`, and false from @objectstack/spec
111-
// 17.4.0, which rewrote it to "Space between widgets, in steps of 0.25rem
112-
// (4 = 1rem)" (objectui#8785). The producer was right to fix its own copy;
113-
// the pin was wrong to name a sentence it does not own, and re-pointing it
114-
// at the new sentence would buy exactly one release before rotting again.
115-
//
116-
// What this test actually claims is narrower and durable: the overlay hands
117-
// the author text they can act on, where the producer's copy reaches for
118-
// DEVELOPER vocabulary — a framework name, a CSS unit — to say the same
119-
// thing. So the control asserts the English carries some of that vocabulary
120-
// and the zh carries none of it. It stays non-vacuous (the English leg must
121-
// fire for the zh leg to mean anything) without pinning any one wording, and
122-
// if the spec ever writes this hint in plain author language the control
123-
// reddens and someone re-reads the overlay — which is the correct outcome,
124-
// not a false alarm: the overlay would have nothing left to do here.
111+
// The control used to read the PRODUCER's English and assert it still
112+
// carried developer vocabulary, so that the zh leg meant something. That leg
113+
// was built to redden once the spec spoke plainly, and it did: the spec's
114+
// hints were rewritten in author language (objectstack#36816). The
115+
// vocabulary test now proves it can fire against a FIXED literal, the hint
116+
// as the spec shipped it before that rewrite, and then holds BOTH the
117+
// producer's English and the zh overlay free of it.
125118
// A framework name, or a CSS length written as an author never would —
126119
// digits welded to a unit. ⚠️ `\brem\b` does NOT work here: the boundary
127120
// before `rem` never matches in `0.25rem`, because `5` is a word character.
128121
const DEVELOPER_UNITS = /tailwind|\d\s*(rem|px)\b/i;
129-
expect(fieldByName(dashboardForm, 'gap')?.helpText).toMatch(DEVELOPER_UNITS);
122+
expect('Space between widgets, in steps of 0.25rem (4 = 1rem)').toMatch(DEVELOPER_UNITS);
123+
expect(fieldByName(dashboardForm, 'gap')?.helpText).not.toMatch(DEVELOPER_UNITS);
130124
expect(gap?.helpText).not.toMatch(DEVELOPER_UNITS);
131125
});
132126

127+
it('no dashboard hint, English or zh, uses developer vocabulary', () => {
128+
const zh = localizeMetadataForm(
129+
dashboardForm as unknown as Record<string, unknown>,
130+
'dashboard',
131+
'zh-CN',
132+
);
133+
// Casing jargon and "config" join the units: the hints the spec shipped
134+
// before objectstack#36816 said "snake_case unique identifier" and
135+
// "Dashboard header config (title, subtitle, actions)".
136+
const DEVELOPER_VOCABULARY = /tailwind|\d\s*(rem|px)\b|snake_case|\bconfig\b/i;
137+
expect('snake_case unique identifier').toMatch(DEVELOPER_VOCABULARY);
138+
const hints = (form: Record<string, unknown> | undefined) =>
139+
sections(form).flatMap((s) => (s.fields ?? []).flatMap((f) => [f, ...(f.fields ?? [])]))
140+
.filter((f) => typeof f.helpText === 'string')
141+
.map((f) => `${f.field}: ${f.helpText}`);
142+
const en = hints(dashboardForm as unknown as Record<string, unknown>);
143+
const zhHints = hints(zh);
144+
// Non-vacuity: both forms carry the nine top-level hints and more.
145+
expect(en.length).toBeGreaterThanOrEqual(9);
146+
expect(zhHints.length).toBeGreaterThanOrEqual(9);
147+
expect(en.filter((h) => DEVELOPER_VOCABULARY.test(h))).toEqual([]);
148+
expect(zhHints.filter((h) => DEVELOPER_VOCABULARY.test(h))).toEqual([]);
149+
});
150+
133151
it('synthesizes ALL of the `header` composite’s sub-rows — a partial list would hide the rest', () => {
134152
const zh = localizeMetadataForm(
135153
dashboardForm as unknown as Record<string, unknown>,

‎ui/packages/app-shell/src/views/metadata-admin/metadata-form-i18n.ts‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -114,25 +114,26 @@ const METADATA_FORM_BUNDLE: TranslationBundle = {
114114
advanced: { label: '高级', description: '无障碍与性能调优。' },
115115
},
116116
fields: {
117-
name: { label: '名称', helpText: 'snake_case 唯一标识' },
118-
label: { label: '显示名称', helpText: '展示给使用者的名称' },
117+
name: { label: '名称', helpText: '仪表盘的唯一内部名称:使用小写字母、数字和下划线,以字母开头(例如 sales_overview)。' },
118+
label: { label: '显示名称', helpText: '使用者看到的仪表盘标题。' },
119119
description: { label: '描述' },
120-
columns: { label: '列数', helpText: '栅格列数(默认 12)' },
121-
// The spec's own hint reaches for developer vocabulary to say this —
122-
// `Grid gap (Tailwind units)` before 17.4.0, and "Space between
123-
// widgets, in steps of 0.25rem (4 = 1rem)" since. Either way it names
124-
// a unit only a developer can act on, so this row says what the author
125-
// can decide rather than transliterating it (objectui#8785).
126-
gap: { label: '间距', helpText: '组件之间的间距,数值越大越松' },
127-
refreshIntervalSeconds: { label: '自动刷新', helpText: '自动刷新间隔(秒),0 表示不自动刷新' },
128-
header: { label: '页眉', helpText: '页眉设置:标题、描述与操作按钮' },
120+
columns: { label: '列数', helpText: '组件排布所用的列数,1 到 24。留空时仪表盘会按组件的宽度自动选择。' },
121+
// The hints of these nine rows are the platform's zh-CN wording
122+
// (`zh-CN.metadata-forms.generated.ts`), copied when the spec's own
123+
// hints were rewritten in author language (objectstack#36816). Before
124+
// that the English gap hint named a unit only a developer can act on
125+
// (`Grid gap (Tailwind units)`, then "in steps of 0.25rem"), and this
126+
// row was hand-worded instead of transliterated (objectui#8785).
127+
gap: { label: '间距', helpText: '组件之间留出的空间。数值越大越松散;留空则使用标准间距。' },
128+
refreshIntervalSeconds: { label: '自动刷新', helpText: '仪表盘重新加载数据的频率(秒)。留空或填 0 表示不自动刷新。' },
129+
header: { label: '页眉', helpText: '仪表盘顶部显示的内容:标题、描述和操作按钮。' },
129130
// All three children of the `header` composite — see the ⛔ note above.
130131
'header.showTitle': { label: '显示标题', helpText: '在页眉中显示仪表盘名称' },
131132
'header.showDescription': { label: '显示描述', helpText: '在页眉中显示仪表盘描述' },
132133
'header.actions': { label: '操作按钮', helpText: '显示在页眉里的操作按钮' },
133-
widgets: { label: '组件', helpText: '仪表盘组件,含位置与尺寸' },
134-
dateRange: { label: '日期范围', helpText: '默认的日期范围选择器' },
135-
globalFilters: { label: '全局筛选', helpText: '应用到全部组件的筛选条件' },
134+
widgets: { label: '组件', helpText: '仪表盘上的图表、数字和表格,以及每一项所在的位置。' },
135+
dateRange: { label: '日期范围', helpText: '打开仪表盘时默认的时间段,以及查看者能否自选日期。' },
136+
globalFilters: { label: '全局筛选', helpText: '查看者可用来一次筛选全部组件,或只筛选你指定组件的筛选条件。' },
136137
},
137138
},
138139
},

0 commit comments

Comments
 (0)