From 31323f0e70720aff07d952421994288d7224bb7f Mon Sep 17 00:00:00 2001 From: Day Dreamer <87640074+HugoXK@users.noreply.github.com> Date: Tue, 17 Nov 2026 08:21:14 +0800 Subject: [PATCH] fix(i18n): the approval cards draw their last four controls in the window's language MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The other owner's waiting line, the per-pair Auto-send from now on link on the in-chat card and on a held reply's bubble, and the friend panel's Decline button and pending tag were handed to `h()` as bare English, and the zh dictionary had no entry for any of them: a Chinese window drew English while both i18n scans stayed green. The four entries now exist and the five draws go through `tr()`; the five baseline pins they no longer need are deleted (163 -> 158), and `--check` stays at 19 bare draws. Docs-not-needed: copy only — the four labels follow the window's language now; no documented behavior changes. Fixes #3032 --- changelog.d/3032-approval-card-copy.fixed.md | 1 + core/client.js | 5 +++ core/src/client/i18n.js | 5 +++ core/test/i18n-missing-entries.baseline.json | 5 --- core/test/i18n-missing-entries.test.js | 11 ++--- patches/ds-bot/0001-core-fixes.patch | 7 ++- patches/ds-bot/0008-client-bundle.patch | 7 ++- .../test/i18n-missing-entries.baseline.json | 5 --- .../files/test/i18n-missing-entries.test.js | 11 ++--- plugins/social/client.js | 10 ++--- plugins/social/test/zh-approval-cards.test.js | 44 +++++++++++++++++-- 11 files changed, 81 insertions(+), 30 deletions(-) create mode 100644 changelog.d/3032-approval-card-copy.fixed.md diff --git a/changelog.d/3032-approval-card-copy.fixed.md b/changelog.d/3032-approval-card-copy.fixed.md new file mode 100644 index 000000000..e4ebd6b26 --- /dev/null +++ b/changelog.d/3032-approval-card-copy.fixed.md @@ -0,0 +1 @@ +The last four English controls on the approval cards — another owner's "Waiting for the owner's approval" line, the per-pair Auto-send from now on link on the in-chat card and on a held reply's bubble, and the friend panel's Decline button and pending tag — now follow the window's language ([#3032](https://github.com/ThinkFlowLab/FlyBot/issues/3032)). diff --git a/core/client.js b/core/client.js index 1deea6e6b..7631654c3 100644 --- a/core/client.js +++ b/core/client.js @@ -255,6 +255,11 @@ var ZH = { "no longer shared": "已不再共享", "Messages waiting for your approval": "等你批准的消息", "Waiting for approval": "等待批准", + // #3032: the four approval-card controls that were still drawn as bare English. + "Waiting for the owner's approval": "等待 owner 批准", + "Auto-send from now on": "以后自动发送", + Decline: "拒绝", + pending: "等待中", "Decide on the reply bubble above.": "在上面的回复气泡里批准。", "Decide in {name}'s chat.": "在 {name} 的聊天里批准。", "Not sent": "未发出", diff --git a/core/src/client/i18n.js b/core/src/client/i18n.js index 6cba8fab8..be91f2dbc 100644 --- a/core/src/client/i18n.js +++ b/core/src/client/i18n.js @@ -222,6 +222,11 @@ const ZH = { 'no longer shared': '已不再共享', 'Messages waiting for your approval': '等你批准的消息', 'Waiting for approval': '等待批准', + // #3032: the four approval-card controls that were still drawn as bare English. + "Waiting for the owner's approval": '等待 owner 批准', + 'Auto-send from now on': '以后自动发送', + Decline: '拒绝', + pending: '等待中', 'Decide on the reply bubble above.': '在上面的回复气泡里批准。', "Decide in {name}'s chat.": '在 {name} 的聊天里批准。', 'Not sent': '未发出', diff --git a/core/test/i18n-missing-entries.baseline.json b/core/test/i18n-missing-entries.baseline.json index 3592e2ca7..b04c0351c 100644 --- a/core/test/i18n-missing-entries.baseline.json +++ b/core/test/i18n-missing-entries.baseline.json @@ -7,8 +7,6 @@ "plugins/social/client.js:Anyone with the number can still join.", "plugins/social/client.js:Ask them to share a Bot", "plugins/social/client.js:Auto-send", - "plugins/social/client.js:Auto-send from now on#1", - "plugins/social/client.js:Auto-send from now on#2", "plugins/social/client.js:Auto-send off", "plugins/social/client.js:Auto-send on", "plugins/social/client.js:Bot Social could not look up that link right now. Try again.", @@ -18,7 +16,6 @@ "plugins/social/client.js:Could not copy. Select the link and copy it by hand.#1", "plugins/social/client.js:Could not copy. Select the link and copy it by hand.#2", "plugins/social/client.js:Could not reach FlyBot. Check that it is still running.", - "plugins/social/client.js:Decline", "plugins/social/client.js:Declined {}.", "plugins/social/client.js:Don't ask each time.#1", "plugins/social/client.js:Don't ask each time.#2", @@ -99,7 +96,6 @@ "plugins/social/client.js:Too many tries for now. Wait a minute and try again.", "plugins/social/client.js:Waiting for others to join…#1", "plugins/social/client.js:Waiting for others to join…#2", - "plugins/social/client.js:Waiting for the owner's approval", "plugins/social/client.js:Which of your Bots talks", "plugins/social/client.js:Which of your Bots to share", "plugins/social/client.js:Who has joined#1", @@ -110,7 +106,6 @@ "plugins/social/client.js:Your own Bots stay shared. {} can share it again.", "plugins/social/client.js:mine#1", "plugins/social/client.js:mine#2", - "plugins/social/client.js:pending", "plugins/social/client.js:the group", "plugins/social/client.js:the room", "plugins/social/client.js:{} (you)", diff --git a/core/test/i18n-missing-entries.test.js b/core/test/i18n-missing-entries.test.js index 1d6a30934..ac1d5d3dd 100644 --- a/core/test/i18n-missing-entries.test.js +++ b/core/test/i18n-missing-entries.test.js @@ -186,15 +186,16 @@ test('glyphs, bare digits and separators drawn as children are not pins', () => }) // The same sentence drawn through an attribute and as a child is two positions in one file, so it -// keeps two pins in #3026's shape: the attribute `#1`, the child `#2`. +// keeps two pins in #3026's shape: the attribute `#1`, the child `#2`. The sample is a sentence with +// no zh entry; #3032 gave `Decline` one, so this test moved to a string that is still a gap. test('a sentence drawn as an attribute and as a child keeps two pins', () => { const source = [ - "h(Button, { title: 'Decline' })", - "h(Button, null, 'Decline')", + "h(Button, { title: 'Reopen the room' })", + "h(Button, null, 'Reopen the room')", ].join('\n') assert.deepEqual(baselineOf(missingCopy(source, 'plugins/sample/client.js')), [ - 'plugins/sample/client.js:Decline#1', - 'plugins/sample/client.js:Decline#2', + 'plugins/sample/client.js:Reopen the room#1', + 'plugins/sample/client.js:Reopen the room#2', ]) }) diff --git a/patches/ds-bot/0001-core-fixes.patch b/patches/ds-bot/0001-core-fixes.patch index 1fec1c80e..0eca5863d 100644 --- a/patches/ds-bot/0001-core-fixes.patch +++ b/patches/ds-bot/0001-core-fixes.patch @@ -852,7 +852,7 @@ diff --git a/src/client/i18n.js b/src/client/i18n.js Content: '内容', 'Referenced {labels}': '引用了 {labels}', ', ': '、', -@@ -41,22 +41,81 @@ const ZH = { +@@ -41,22 +41,86 @@ const ZH = { ' and ': '、', and: '和', '{count} members': '{count} 位成员', @@ -902,6 +902,11 @@ diff --git a/src/client/i18n.js b/src/client/i18n.js + 'no longer shared': '已不再共享', + 'Messages waiting for your approval': '等你批准的消息', + 'Waiting for approval': '等待批准', ++ // #3032: the four approval-card controls that were still drawn as bare English. ++ "Waiting for the owner's approval": '等待 owner 批准', ++ 'Auto-send from now on': '以后自动发送', ++ Decline: '拒绝', ++ pending: '等待中', + 'Decide on the reply bubble above.': '在上面的回复气泡里批准。', + "Decide in {name}'s chat.": '在 {name} 的聊天里批准。', + 'Not sent': '未发出', diff --git a/patches/ds-bot/0008-client-bundle.patch b/patches/ds-bot/0008-client-bundle.patch index b33574079..92d16e07c 100644 --- a/patches/ds-bot/0008-client-bundle.patch +++ b/patches/ds-bot/0008-client-bundle.patch @@ -160,7 +160,7 @@ diff --git a/client.js b/client.js Content: "内容", "Referenced {labels}": "引用了 {labels}", ", ": "、", -@@ -78,21 +78,80 @@ var ZH = { +@@ -78,21 +78,85 @@ var ZH = { " and ": "、", and: "和", "{count} members": "{count} 位成员", @@ -209,6 +209,11 @@ diff --git a/client.js b/client.js + "no longer shared": "已不再共享", + "Messages waiting for your approval": "等你批准的消息", + "Waiting for approval": "等待批准", ++ // #3032: the four approval-card controls that were still drawn as bare English. ++ "Waiting for the owner's approval": "等待 owner 批准", ++ "Auto-send from now on": "以后自动发送", ++ Decline: "拒绝", ++ pending: "等待中", + "Decide on the reply bubble above.": "在上面的回复气泡里批准。", + "Decide in {name}'s chat.": "在 {name} 的聊天里批准。", + "Not sent": "未发出", diff --git a/patches/ds-bot/files/test/i18n-missing-entries.baseline.json b/patches/ds-bot/files/test/i18n-missing-entries.baseline.json index 3592e2ca7..b04c0351c 100644 --- a/patches/ds-bot/files/test/i18n-missing-entries.baseline.json +++ b/patches/ds-bot/files/test/i18n-missing-entries.baseline.json @@ -7,8 +7,6 @@ "plugins/social/client.js:Anyone with the number can still join.", "plugins/social/client.js:Ask them to share a Bot", "plugins/social/client.js:Auto-send", - "plugins/social/client.js:Auto-send from now on#1", - "plugins/social/client.js:Auto-send from now on#2", "plugins/social/client.js:Auto-send off", "plugins/social/client.js:Auto-send on", "plugins/social/client.js:Bot Social could not look up that link right now. Try again.", @@ -18,7 +16,6 @@ "plugins/social/client.js:Could not copy. Select the link and copy it by hand.#1", "plugins/social/client.js:Could not copy. Select the link and copy it by hand.#2", "plugins/social/client.js:Could not reach FlyBot. Check that it is still running.", - "plugins/social/client.js:Decline", "plugins/social/client.js:Declined {}.", "plugins/social/client.js:Don't ask each time.#1", "plugins/social/client.js:Don't ask each time.#2", @@ -99,7 +96,6 @@ "plugins/social/client.js:Too many tries for now. Wait a minute and try again.", "plugins/social/client.js:Waiting for others to join…#1", "plugins/social/client.js:Waiting for others to join…#2", - "plugins/social/client.js:Waiting for the owner's approval", "plugins/social/client.js:Which of your Bots talks", "plugins/social/client.js:Which of your Bots to share", "plugins/social/client.js:Who has joined#1", @@ -110,7 +106,6 @@ "plugins/social/client.js:Your own Bots stay shared. {} can share it again.", "plugins/social/client.js:mine#1", "plugins/social/client.js:mine#2", - "plugins/social/client.js:pending", "plugins/social/client.js:the group", "plugins/social/client.js:the room", "plugins/social/client.js:{} (you)", diff --git a/patches/ds-bot/files/test/i18n-missing-entries.test.js b/patches/ds-bot/files/test/i18n-missing-entries.test.js index 1d6a30934..ac1d5d3dd 100644 --- a/patches/ds-bot/files/test/i18n-missing-entries.test.js +++ b/patches/ds-bot/files/test/i18n-missing-entries.test.js @@ -186,15 +186,16 @@ test('glyphs, bare digits and separators drawn as children are not pins', () => }) // The same sentence drawn through an attribute and as a child is two positions in one file, so it -// keeps two pins in #3026's shape: the attribute `#1`, the child `#2`. +// keeps two pins in #3026's shape: the attribute `#1`, the child `#2`. The sample is a sentence with +// no zh entry; #3032 gave `Decline` one, so this test moved to a string that is still a gap. test('a sentence drawn as an attribute and as a child keeps two pins', () => { const source = [ - "h(Button, { title: 'Decline' })", - "h(Button, null, 'Decline')", + "h(Button, { title: 'Reopen the room' })", + "h(Button, null, 'Reopen the room')", ].join('\n') assert.deepEqual(baselineOf(missingCopy(source, 'plugins/sample/client.js')), [ - 'plugins/sample/client.js:Decline#1', - 'plugins/sample/client.js:Decline#2', + 'plugins/sample/client.js:Reopen the room#1', + 'plugins/sample/client.js:Reopen the room#2', ]) }) diff --git a/plugins/social/client.js b/plugins/social/client.js index df78f7171..37cf5a510 100644 --- a/plugins/social/client.js +++ b/plugins/social/client.js @@ -2157,7 +2157,7 @@ window.__ModuleLoader__.load({ : String(text).replace(/\{(\w+)\}/g, (_, key) => String(params?.[key] ?? ''))) const place = item.place return h('div', { className: 'fs-hold fs-chat-approval', 'data-flybot': 'chat-approval', 'data-role': 'other', role: 'status' }, - h('div', { className: 'fs-name' }, WAITING_OTHERS), + h('div', { className: 'fs-name' }, tr(WAITING_OTHERS)), place?.bubble ? h('div', { className: 'fs-sub', 'data-flybot': 'waiting-place' }, tr('Decide on the reply bubble above.')) : null, place?.chatId ? h('div', { className: 'fs-sub', 'data-flybot': 'waiting-place' }, tr("Decide in {name}'s chat.", { name: place.name })) : null, place?.chatId && typeof onOpen === 'function' @@ -2199,7 +2199,7 @@ window.__ModuleLoader__.load({ h('button', { type: 'button', className: 'fs-btn fs-btn-sm fs-btn-primary', disabled: !!busy, onClick: () => onDecide?.(item, 'approve') }, tr('Approve')), h('button', { type: 'button', className: 'fs-btn fs-btn-sm', disabled: !!busy, onClick: () => onDecide?.(item, 'reject') }, tr('Reject'))), // Two buttons are the decision; the standing choice is a quiet link, not a third button (#260). - h('button', { type: 'button', className: 'fs-link fs-hold-always', 'data-flybot': 'hold-always', disabled: !!busy, onClick: () => onDecide?.(item, 'always') }, AUTO_SEND_LINK))) + h('button', { type: 'button', className: 'fs-link fs-hold-always', 'data-flybot': 'hold-always', disabled: !!busy, onClick: () => onDecide?.(item, 'always') }, tr(AUTO_SEND_LINK)))) } function approvalsForOpenChat(items, { sessionId, room, bot, roster } = {}) { @@ -2857,7 +2857,7 @@ window.__ModuleLoader__.load({ h('span', { className: 'fs-hold-decide' }, h('button', { type: 'button', className: 'fs-btn fs-btn-sm fs-btn-primary', disabled: busy, onClick: () => onDecide('approve') }, tr('Approve')), h('button', { type: 'button', className: 'fs-btn fs-btn-sm', disabled: busy, onClick: () => onDecide('reject') }, tr('Reject'))), - h('button', { type: 'button', className: 'fs-link fs-hold-always', 'data-flybot': 'hold-always', disabled: busy, onClick: () => onDecide('always') }, AUTO_SEND_LINK))) + h('button', { type: 'button', className: 'fs-link fs-hold-always', 'data-flybot': 'hold-always', disabled: busy, onClick: () => onDecide('always') }, tr(AUTO_SEND_LINK)))) } function FriendBotRow({ bot, chat, renderBot, busy, onRemove }) { @@ -3521,7 +3521,7 @@ window.__ModuleLoader__.load({ item.message ? h('span', { className: 'fs-sub fs-msg' }, item.message) : null), h('span', { className: 'fs-actions' }, h('button', { type: 'button', className: 'fs-btn fs-btn-sm', disabled: busy, onClick: () => respond(item, 'accept') }, tr('Accept')), - h('button', { type: 'button', className: 'fs-btn fs-btn-sm', disabled: busy, onClick: () => respond(item, 'decline') }, 'Decline'))))) : null, + h('button', { type: 'button', className: 'fs-btn fs-btn-sm', disabled: busy, onClick: () => respond(item, 'decline') }, tr('Decline')))))) : null, outgoing.length ? h('div', { className: 'bt-social-outgoing' }, h('div', { className: 'fs-label' }, tr('Waiting for them to accept')), outgoing.map(item => h('div', { key: item.relationshipId ?? item.handle, className: 'fs-row' }, @@ -3529,7 +3529,7 @@ window.__ModuleLoader__.load({ h('span', { className: 'fs-text' }, h('span', { className: 'fs-name' }, item.name ?? item.handle), item.name ? h('span', { className: 'fs-sub' }, item.handle) : null), - h('span', { className: 'fs-tag' }, 'pending')))) : null, + h('span', { className: 'fs-tag' }, tr('pending'))))) : null, onDone ? h('div', { className: 'fs-line', 'data-flybot': 'add-friend-done', style: { padding: '6px 10px 2px', justifyContent: 'flex-end' } }, h('button', { type: 'button', className: 'fs-btn fs-btn-sm', onClick: onDone }, tr('Done'))) : null) } diff --git a/plugins/social/test/zh-approval-cards.test.js b/plugins/social/test/zh-approval-cards.test.js index aa63e8d3b..8b6bf6d39 100644 --- a/plugins/social/test/zh-approval-cards.test.js +++ b/plugins/social/test/zh-approval-cards.test.js @@ -99,12 +99,12 @@ const hostT = (text, params) => { return String(hit).replace(/\{(\w+)\}/g, (_, key) => String(params?.[key] ?? '')) } -function fixtures({ incoming = [], grants = [], friends = undefined } = {}) { +function fixtures({ incoming = [], outgoing = [], grants = [], friends = undefined } = {}) { globalThis.__flybot__ = { t: hostT, call: (endpoint) => { if (endpoint === 'social/access') return Promise.resolve({ grants, note: '' }) - if (endpoint === 'social/overview') return Promise.resolve({ incoming, outgoing: [] }) + if (endpoint === 'social/overview') return Promise.resolve({ incoming, outgoing }) if (endpoint === 'social/status') return Promise.resolve({ bots: [], home: '' }) if (endpoint === 'social/face-rooms') return Promise.resolve({ rooms: [] }) if (endpoint === 'social/settings') return Promise.resolve({}) @@ -218,6 +218,44 @@ test('#3004: the two inline confirmations speak the window’s language', async } finally { delete globalThis.__flybot__ } }) +// #3032: the four controls #3004 left English — the other owner's card title, the per-pair Auto-send +// link on both cards, and the friend row's Decline and pending tag. Each one is drawn on the card a +// reader sees, so each is asserted where it is drawn and the English is asserted absent. +test('#3032: the last four approval-card controls speak the window’s language', async () => { + const app = loadApp() + const english = "Waiting for the owner's approval" + fixtures({ incoming: [{ relationshipId: 'rel9', handle: '@eve.home', name: 'Eve' }], outgoing: [{ relationshipId: 'rel2', handle: '@sam.home', name: 'Sam' }] }) + try { + const mine = { hooks: {}, effects: [], props: { item: pendingItem, canDecide: true, onDecide() {} } } + const owner = drawn(render(app.ChatApproval, mine)) + assert.ok(owner.includes(zh['Auto-send from now on']), `expected ${zh['Auto-send from now on']} on the owner card, saw ${JSON.stringify(owner)}`) + assert.ok(!owner.includes('Auto-send from now on'), 'the English Auto-send link is still drawn on the owner card') + + const held = { hooks: {}, effects: [], props: { held: { id: 'h1', from: '@me.home', to: '@eve.home' }, decide: async () => {} } } + const bubble = drawn(render(app.HeldReplyCard, held)) + assert.ok(bubble.includes(zh['Auto-send from now on']), `expected ${zh['Auto-send from now on']} on the held-reply card, saw ${JSON.stringify(bubble)}`) + assert.ok(!bubble.includes('Auto-send from now on'), 'the English Auto-send link is still drawn on the held-reply card') + + // Another owner's card is the one the core dock renders with its own `t` prop (flybot-slots.js + // passes it), so the test hands it the same translator the dock does. + const other = { hooks: {}, effects: [], props: { item: pendingItem, canDecide: false, t: hostT } } + const peer = drawn(render(app.ChatApproval, other)) + assert.ok(peer.includes(zh[english]), `expected ${zh[english]} on another owner's card, saw ${JSON.stringify(peer)}`) + assert.ok(!peer.includes(english), 'the English waiting line is still drawn on another owner’s card') + + const friend = { hooks: {}, effects: [], props: { onDone() {} } } + render(app.AddFriend, friend) + runEffects(friend) + await tick() + await tick() + const words = drawn(render(app.AddFriend, friend)) + for (const key of ['Decline', 'pending']) { + assert.ok(words.includes(zh[key]), `expected ${zh[key]} (${key}) on the friend panel, saw ${JSON.stringify(words)}`) + assert.ok(!words.includes(key), `the English ${JSON.stringify(key)} is still drawn on the friend panel`) + } + } finally { delete globalThis.__flybot__ } +}) + // The other direction: with no translator bound, the same cards keep today's English byte for byte // (a zh window is the only thing this change is allowed to move). test('#3004: with no translator the cards keep today’s English', () => { @@ -226,7 +264,7 @@ test('#3004: with no translator the cards keep today’s English', () => { try { const inst = { hooks: {}, effects: [], props: { item: pendingItem, canDecide: true, onDecide() {} } } const words = drawn(render(app.ChatApproval, inst)) - for (const key of ['Waiting for approval', 'Show more', 'Approve', 'Reject']) { + for (const key of ['Waiting for approval', 'Show more', 'Approve', 'Reject', 'Auto-send from now on']) { assert.ok(words.includes(key), `expected ${JSON.stringify(key)}, saw ${JSON.stringify(words)}`) } } finally { delete globalThis.__flybot__ }