From 225d0af8ba8f9ddcdd9c609fa28cca854700e245 Mon Sep 17 00:00:00 2001 From: Danyang Chen Date: Fri, 20 Nov 2026 00:50:03 +0800 Subject: [PATCH] Read the Sharing page invite hint and room hints in the window's language The hint above a Bot's invite link and the rooms a grant reaches (In use in N rooms, This room only, the +N more tail) drew English in a zh window. They go through tr() now, with six zh keys; the two i18n baselines lose those five pins. Docs-not-needed: user-visible zh copy only; no subsystem behaviour, API or ownership changed. Fixes #3229 --- changelog.d/3114-sharing-rooms-zh.fixed.md | 1 + core/client.js | 9 +- core/src/client/i18n.js | 7 + core/test/i18n-missing-entries.baseline.json | 3 - core/test/i18n-template-draws.baseline.json | 2 - patches/ds-bot/0001-core-fixes.patch | 9 +- patches/ds-bot/0008-client-bundle.patch | 11 +- .../test/i18n-missing-entries.baseline.json | 3 - .../test/i18n-template-draws.baseline.json | 2 - plugins/social/client.js | 10 +- plugins/social/test/add-friend-i18n.test.js | 2 +- .../social/test/friend-settings-i18n.test.js | 2 +- plugins/social/test/sharing-page-i18n.test.js | 2 +- .../social/test/sharing-rooms-i18n.test.js | 144 ++++++++++++++++++ 14 files changed, 187 insertions(+), 20 deletions(-) create mode 100644 changelog.d/3114-sharing-rooms-zh.fixed.md create mode 100644 plugins/social/test/sharing-rooms-i18n.test.js diff --git a/changelog.d/3114-sharing-rooms-zh.fixed.md b/changelog.d/3114-sharing-rooms-zh.fixed.md new file mode 100644 index 000000000..1bbc8761e --- /dev/null +++ b/changelog.d/3114-sharing-rooms-zh.fixed.md @@ -0,0 +1 @@ +A Bot’s Sharing page now reads in the window’s language where it still did not: the hint above the invite link (with and without the Revoke tail) and the rooms each grant reaches, including the “+N more” count and the room-only line ([#3114](https://github.com/ThinkFlowLab/FlyBot/issues/3114)). diff --git a/core/client.js b/core/client.js index 6b48972f4..e3f6603b5 100644 --- a/core/client.js +++ b/core/client.js @@ -1823,7 +1823,14 @@ var HOST_ZH = { "QR code for this room invite": "这个房间邀请的二维码", "Scan to open this room": "扫码打开这个房间", "Anyone with the link can join while the room is open.": "只要房间还开着,拿到链接的人都能加入。", - "Bot Social did not send an invite. Try again.": "Bot Social 没有发来邀请,请重试。" + "Bot Social did not send an invite. Try again.": "Bot Social 没有发来邀请,请重试。", + // #3114 cut 26: the invite hint on a Bot's Sharing page and the rooms a grant reaches. + "Invite grants {bot} only.": "邀请只把 {bot} 授权给对方。", + "Invite grants {bot} only. Revoke anytime in People with access.": "邀请只把 {bot} 授权给对方。随时可以在「可访问的人」里撤销。", + "In use in {n} room: ": "正在 {n} 个房间里使用:", + "In use in {n} rooms: ": "正在 {n} 个房间里使用:", + "This room only: ": "只在这个房间使用:", + " +{n} more": ",还有 {n} 个" }; Object.assign(ZH, HOST_ZH); var fill = (text2, params) => params ? text2.replace(/\{(\w+)\}/g, (match, name) => name in params ? String(params[name]) : match) : text2; diff --git a/core/src/client/i18n.js b/core/src/client/i18n.js index 7bac79030..d7e1d7d67 100644 --- a/core/src/client/i18n.js +++ b/core/src/client/i18n.js @@ -1784,6 +1784,13 @@ const HOST_ZH = { 'Scan to open this room': '扫码打开这个房间', 'Anyone with the link can join while the room is open.': '只要房间还开着,拿到链接的人都能加入。', 'Bot Social did not send an invite. Try again.': 'Bot Social 没有发来邀请,请重试。', + // #3114 cut 26: the invite hint on a Bot's Sharing page and the rooms a grant reaches. + 'Invite grants {bot} only.': '邀请只把 {bot} 授权给对方。', + 'Invite grants {bot} only. Revoke anytime in People with access.': '邀请只把 {bot} 授权给对方。随时可以在「可访问的人」里撤销。', + 'In use in {n} room: ': '正在 {n} 个房间里使用:', + 'In use in {n} rooms: ': '正在 {n} 个房间里使用:', + 'This room only: ': '只在这个房间使用:', + ' +{n} more': ',还有 {n} 个', } Object.assign(ZH, HOST_ZH) diff --git a/core/test/i18n-missing-entries.baseline.json b/core/test/i18n-missing-entries.baseline.json index 9718dfb97..55cf94e87 100644 --- a/core/test/i18n-missing-entries.baseline.json +++ b/core/test/i18n-missing-entries.baseline.json @@ -1,10 +1,8 @@ { "version": 1, "entries": [ - "plugins/social/client.js: +{} more", "plugins/social/client.js:Chat paused", "plugins/social/client.js:Could not reach FlyBot. Check that it is still running.", - "plugins/social/client.js:In use in {} room{}: ", "plugins/social/client.js:Past rooms", "plugins/social/client.js:Remove this Bot from Friends' Bots and from your groups. This does not unfriend the owner.", "plugins/social/client.js:Social is not running: the plugin did not start. See Settings → Feedback.", @@ -12,7 +10,6 @@ "plugins/social/client.js:Social#2", "plugins/social/client.js:The FlyBot host did not answer (HTTP {}). Reload the page; if this keeps happening, restart FlyBot web.", "plugins/social/client.js:This invite was already used. Ask your friend for a new one.", - "plugins/social/client.js:This room only: ", "plugins/social/client.js:the room", "plugins/timeline/client.js:Communication map: who sent requests to whom", "plugins/timeline/client.js:Copy report", diff --git a/core/test/i18n-template-draws.baseline.json b/core/test/i18n-template-draws.baseline.json index cef782aae..f717ab608 100644 --- a/core/test/i18n-template-draws.baseline.json +++ b/core/test/i18n-template-draws.baseline.json @@ -3,8 +3,6 @@ "entries": [ "plugins/social/client.js:Auto-send {} → room", "plugins/social/client.js:Auto-send {}'s room messages", - "plugins/social/client.js:Invite grants {} only.", - "plugins/social/client.js:Invite grants {} only. Revoke anytime in People with access.", "plugins/social/client.js:{} Send your message again: it starts a new chat.", "plugins/timeline/client.js:Could not copy the report: {}", "plugins/timeline/client.js:Last {}", diff --git a/patches/ds-bot/0001-core-fixes.patch b/patches/ds-bot/0001-core-fixes.patch index b95b86694..e66666693 100644 --- a/patches/ds-bot/0001-core-fixes.patch +++ b/patches/ds-bot/0001-core-fixes.patch @@ -2055,7 +2055,7 @@ diff --git a/src/client/i18n.js b/src/client/i18n.js 'The admin must be a member of the group': '管理员必须是群成员', 'Unknown group chat': '找不到这个群聊', 'Hand the admin role to another member instead of leaving the group without one': '请把管理员交给其他成员,不要让群聊没有管理员', -@@ -905,6 +905,40 @@ const HOST_ZH = { +@@ -905,6 +905,47 @@ const HOST_ZH = { 'Write the entry to save.': '请写下要保存的内容。', 'This DeepSeek Harness has no folder chooser': '这个 DeepSeek Harness 没有文件夹选择窗口', 'This DeepSeek Harness cannot list folders': '这个 DeepSeek Harness 不能列出文件夹', @@ -2093,6 +2093,13 @@ diff --git a/src/client/i18n.js b/src/client/i18n.js + 'Scan to open this room': '扫码打开这个房间', + 'Anyone with the link can join while the room is open.': '只要房间还开着,拿到链接的人都能加入。', + 'Bot Social did not send an invite. Try again.': 'Bot Social 没有发来邀请,请重试。', ++ // #3114 cut 26: the invite hint on a Bot's Sharing page and the rooms a grant reaches. ++ 'Invite grants {bot} only.': '邀请只把 {bot} 授权给对方。', ++ 'Invite grants {bot} only. Revoke anytime in People with access.': '邀请只把 {bot} 授权给对方。随时可以在「可访问的人」里撤销。', ++ 'In use in {n} room: ': '正在 {n} 个房间里使用:', ++ 'In use in {n} rooms: ': '正在 {n} 个房间里使用:', ++ 'This room only: ': '只在这个房间使用:', ++ ' +{n} more': ',还有 {n} 个', } Object.assign(ZH, HOST_ZH) diff --git a/patches/ds-bot/0008-client-bundle.patch b/patches/ds-bot/0008-client-bundle.patch index c93e14386..6053b48a2 100644 --- a/patches/ds-bot/0008-client-bundle.patch +++ b/patches/ds-bot/0008-client-bundle.patch @@ -1317,7 +1317,7 @@ diff --git a/client.js b/client.js "The admin must be a member of the group": "管理员必须是群成员", "Unknown group chat": "找不到这个群聊", "Hand the admin role to another member instead of leaving the group without one": "请把管理员交给其他成员,不要让群聊没有管理员", -@@ -951,10 +951,44 @@ var HOST_ZH = { +@@ -951,10 +951,51 @@ var HOST_ZH = { "The model wrote nothing": "模型没有输出内容", "Write the entry to save.": "请写下要保存的内容。", "This DeepSeek Harness has no folder chooser": "这个 DeepSeek Harness 没有文件夹选择窗口", @@ -1356,7 +1356,14 @@ diff --git a/client.js b/client.js + "QR code for this room invite": "这个房间邀请的二维码", + "Scan to open this room": "扫码打开这个房间", + "Anyone with the link can join while the room is open.": "只要房间还开着,拿到链接的人都能加入。", -+ "Bot Social did not send an invite. Try again.": "Bot Social 没有发来邀请,请重试。" ++ "Bot Social did not send an invite. Try again.": "Bot Social 没有发来邀请,请重试。", ++ // #3114 cut 26: the invite hint on a Bot's Sharing page and the rooms a grant reaches. ++ "Invite grants {bot} only.": "邀请只把 {bot} 授权给对方。", ++ "Invite grants {bot} only. Revoke anytime in People with access.": "邀请只把 {bot} 授权给对方。随时可以在「可访问的人」里撤销。", ++ "In use in {n} room: ": "正在 {n} 个房间里使用:", ++ "In use in {n} rooms: ": "正在 {n} 个房间里使用:", ++ "This room only: ": "只在这个房间使用:", ++ " +{n} more": ",还有 {n} 个" }; Object.assign(ZH, HOST_ZH); -var fill = (text, params) => params ? text.replace(/\{(\w+)\}/g, (match, name) => name in params ? String(params[name]) : match) : text; 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 9718dfb97..55cf94e87 100644 --- a/patches/ds-bot/files/test/i18n-missing-entries.baseline.json +++ b/patches/ds-bot/files/test/i18n-missing-entries.baseline.json @@ -1,10 +1,8 @@ { "version": 1, "entries": [ - "plugins/social/client.js: +{} more", "plugins/social/client.js:Chat paused", "plugins/social/client.js:Could not reach FlyBot. Check that it is still running.", - "plugins/social/client.js:In use in {} room{}: ", "plugins/social/client.js:Past rooms", "plugins/social/client.js:Remove this Bot from Friends' Bots and from your groups. This does not unfriend the owner.", "plugins/social/client.js:Social is not running: the plugin did not start. See Settings → Feedback.", @@ -12,7 +10,6 @@ "plugins/social/client.js:Social#2", "plugins/social/client.js:The FlyBot host did not answer (HTTP {}). Reload the page; if this keeps happening, restart FlyBot web.", "plugins/social/client.js:This invite was already used. Ask your friend for a new one.", - "plugins/social/client.js:This room only: ", "plugins/social/client.js:the room", "plugins/timeline/client.js:Communication map: who sent requests to whom", "plugins/timeline/client.js:Copy report", diff --git a/patches/ds-bot/files/test/i18n-template-draws.baseline.json b/patches/ds-bot/files/test/i18n-template-draws.baseline.json index cef782aae..f717ab608 100644 --- a/patches/ds-bot/files/test/i18n-template-draws.baseline.json +++ b/patches/ds-bot/files/test/i18n-template-draws.baseline.json @@ -3,8 +3,6 @@ "entries": [ "plugins/social/client.js:Auto-send {} → room", "plugins/social/client.js:Auto-send {}'s room messages", - "plugins/social/client.js:Invite grants {} only.", - "plugins/social/client.js:Invite grants {} only. Revoke anytime in People with access.", "plugins/social/client.js:{} Send your message again: it starts a new chat.", "plugins/timeline/client.js:Could not copy the report: {}", "plugins/timeline/client.js:Last {}", diff --git a/plugins/social/client.js b/plugins/social/client.js index 56efa1ffa..4c57475a8 100644 --- a/plugins/social/client.js +++ b/plugins/social/client.js @@ -58,11 +58,13 @@ window.__ModuleLoader__.load({ const roomHint = (kind, rooms, skip) => { const rows = roomList(rooms, skip) if (!rows.length) return null - const head = kind === 'use' ? `In use in ${rows.length} room${rows.length === 1 ? '' : 's'}: ` : 'This room only: ' + const head = kind === 'use' + ? tr(rows.length === 1 ? 'In use in {n} room: ' : 'In use in {n} rooms: ', { n: rows.length }) + : tr('This room only: ') const build = (count, clip) => { const pick = rows.slice(0, count).map(row => (clip ? clipRoom(row.label) : row.label)) const rest = rows.length - pick.length - return head + pick.join(', ') + (rest > 0 ? ` +${rest} more` : '') + return head + pick.join(', ') + (rest > 0 ? tr(' +{n} more', { n: rest }) : '') } const top = Math.min(ROOM_HINT_NAMES, rows.length) // Short lists print whole names; a long-lived share falls back to clipped names so the count still shows. @@ -3857,7 +3859,9 @@ window.__ModuleLoader__.load({ const copy = (text, withText) => { void copyInvite(text, bot.name, withText).then(setNote) } // Revoke is mentioned once People with access has someone to revoke (#499). return h('div', { className: 'fs fs-card', 'data-flybot': 'invite-to-bot' }, - h('div', { className: 'fs-hint', 'data-flybot': 'invite-hint-sharing' }, revocable ? `Invite grants ${bot.name} only. Revoke anytime in People with access.` : `Invite grants ${bot.name} only.`), + h('div', { className: 'fs-hint', 'data-flybot': 'invite-hint-sharing' }, revocable + ? tr('Invite grants {bot} only. Revoke anytime in People with access.', { bot: bot.name }) + : tr('Invite grants {bot} only.', { bot: bot.name })), inviteControls({ botName: bot.name, invite, busy, onMint: () => create(true), onCopy: copy, onNew: () => create(false) }), note ? h('div', { className: 'fs-status', role: 'status', 'data-tone': note.tone }, note.text) : null) } diff --git a/plugins/social/test/add-friend-i18n.test.js b/plugins/social/test/add-friend-i18n.test.js index 939bd1f30..274825d10 100644 --- a/plugins/social/test/add-friend-i18n.test.js +++ b/plugins/social/test/add-friend-i18n.test.js @@ -116,7 +116,7 @@ test('#3114 cut 22: the baselines lose these draws and the dictionary gains the assert.deepEqual(still, [], `${file.replace('.baseline.json', '')} still pins ${still[0]}`) } // The three baselines shrink by exactly these draws and nothing else does: the ratchet's numbers. - assert.deepEqual([entriesOf('i18n-plugins.baseline.json').length, entriesOf('i18n-template-draws.baseline.json').length, entriesOf('i18n-missing-entries.baseline.json').length], [12, 14, 51]) + assert.deepEqual([entriesOf('i18n-plugins.baseline.json').length, entriesOf('i18n-template-draws.baseline.json').length, entriesOf('i18n-missing-entries.baseline.json').length], [12, 12, 48]) // Every new key is the dictionary's, and each answers with Chinese. for (const key of [ 'Accept an invite', 'Invite a friend', 'Paste invite link or code', diff --git a/plugins/social/test/friend-settings-i18n.test.js b/plugins/social/test/friend-settings-i18n.test.js index ce72bc332..0ffd0fc0b 100644 --- a/plugins/social/test/friend-settings-i18n.test.js +++ b/plugins/social/test/friend-settings-i18n.test.js @@ -149,7 +149,7 @@ test('#3114 cut 23: the two baselines lose these draws and nothing else', () => entriesOf('i18n-plugins.baseline.json').length, entriesOf('i18n-template-draws.baseline.json').length, entriesOf('i18n-missing-entries.baseline.json').length, - ], [12, 14, 51]) + ], [12, 12, 48]) // People with access is reused, never added twice; the same for the friend's own fallback name. assert.equal(zh['Your friend'], '你的朋友') }) diff --git a/plugins/social/test/sharing-page-i18n.test.js b/plugins/social/test/sharing-page-i18n.test.js index 5cbf08403..3a1b170ff 100644 --- a/plugins/social/test/sharing-page-i18n.test.js +++ b/plugins/social/test/sharing-page-i18n.test.js @@ -145,7 +145,7 @@ test('#3114 cut 20: the three baselines lose these draws', () => { } // The baselines shrink by exactly these draws and nothing else does: the totals are the ratchet's // numbers, and a later cut that moves them moves these numbers with it. - assert.deepEqual([entriesOf('i18n-plugins.baseline.json').length, entriesOf('i18n-template-draws.baseline.json').length, entriesOf('i18n-missing-entries.baseline.json').length], [12, 14, 51]) + assert.deepEqual([entriesOf('i18n-plugins.baseline.json').length, entriesOf('i18n-template-draws.baseline.json').length, entriesOf('i18n-missing-entries.baseline.json').length], [12, 12, 48]) // A host with no translator keeps the English it drew before this change, character for // character — `tr()` replaces a string only when the host answers for it. diff --git a/plugins/social/test/sharing-rooms-i18n.test.js b/plugins/social/test/sharing-rooms-i18n.test.js new file mode 100644 index 000000000..ef4e0e812 --- /dev/null +++ b/plugins/social/test/sharing-rooms-i18n.test.js @@ -0,0 +1,144 @@ +// #3114 cut 26: on a Bot's own Sharing page the hint above the invite link (`Invite grants +// only.`, with and without the Revoke tail) and the rooms a grant reaches (`In use in N rooms: …`, +// `This room only: …`, ` +N more`) drew English in a zh window. This pins them: a zh window reads +// the dictionary's words, a window whose host has no translator keeps today's English word for +// word, and the two baselines lose the five pins those draws held. +import assert from 'node:assert/strict' +import { readFileSync } from 'node:fs' +import { test } from 'node:test' +import { runInNewContext } from 'node:vm' +import { DICTIONARY } from '../../../core/src/client/i18n.js' + +const zh = DICTIONARY.zh +// The language a window runs in: `t` answers with the Chinese dictionary for a key it carries and +// echoes anything else, which is what the host's own translator does for an entry it lacks. +const translator = (text, params) => { + const translated = Object.hasOwn(zh, text) ? zh[text] : String(text) + return params ? translated.replace(/\{(\w+)\}/g, (match, name) => (name in params ? String(params[name]) : match)) : translated +} +const zhWindow = { t: translator, slots: { register: () => () => {} }, call: async () => ({}) } +const bareWindow = { slots: { register: () => () => {} }, call: async () => ({}) } + +// The client is a classic script that registers its factory on `window`, and the plugin reads +// `__flybot__` off the global object at render time — so the sandbox is that global object. +// `states` seeds the component's useState calls in order (a card that reads a loaded list). +function loadApp(flybot, states = []) { + const registered = [] + const sandbox = { window: { __ModuleLoader__: { load: entry => registered.push(entry) } }, console, setTimeout, clearTimeout, setInterval, clearInterval } + sandbox.globalThis = sandbox + sandbox.__flybot__ = flybot + runInNewContext(readFileSync(new URL('../client.js', import.meta.url), 'utf8'), sandbox) + let seed = 0 + const createElement = (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat() }) + return registered[0].factory(() => ({ + createElement, Fragment: 'F', useEffect() {}, useRef: value => ({ current: value }), + useState: value => [seed < states.length ? states[seed++] : value, () => {}], + })) +} + +// These cards are plain render functions once the effects are inert, so the tree is the render. +// Text is every string the tree paints, in draw order. +function draw(node, all = []) { + if (!node || typeof node !== 'object') return all + if (typeof node.type === 'function') return draw(node.type(node.props), all) + for (const child of node.children ?? []) { + if (typeof child === 'string') { if (child.trim()) all.push(child) } else draw(child, all) + } + return all +} +// The first node the tree paints that the predicate claims, so a hint's `title` can be read too. +const findNode = (node, match) => { + if (!node || typeof node !== 'object') return undefined + if (typeof node.type === 'function') return findNode(node.type(node.props), match) + if (match(node)) return node + return (node.children ?? []).map(child => findNode(child, match)).find(Boolean) +} +const textOf = (node, id) => findNode(node, n => n.props?.['data-flybot'] === id)?.children.join('') + +const room = (id, name) => ({ id, name }) +const bot = { id: 'b1', name: 'Mine' } +const grant = { id: 'g1', name: 'Eve', home: '@eve.home', person: 'Eve', grantee: '@eve.home', autoSend: false, rooms: [room('r1', 'Den'), room('r2', 'Lab')] } + +test('#3114 cut 26: the rooms a grant reaches read in the window’s language', () => { + const app = loadApp(zhWindow) + // Two rooms: the hint counts them and the tooltip still carries every name, untruncated. + const two = app.roomHint('use', [room('r1', 'Den'), room('r2', 'Lab')]) + assert.equal(two.text, '正在 2 个房间里使用:Den, Lab') + assert.equal(two.title, 'Den\nLab', 'the tooltip is still the whole list') + assert.deepEqual(Array.from(two.ids), ['r1', 'r2']) + // One room keeps the singular English form; its zh key says the same words. + assert.equal(app.roomHint('use', [room('r1', 'Den')]).text, '正在 1 个房间里使用:Den') + // Three names print whole and the fourth becomes the count — the truncation itself is untouched. + assert.equal(app.roomHint('use', [room('r1', 'Den'), room('r2', 'Lab'), room('r3', 'Hall'), room('r4', 'Loft')]).text, + '正在 4 个房间里使用:Den, Lab, Hall,还有 1 个') + // A grant used only face to face keeps its own words. + assert.equal(app.roomHint('only', [room('r1', 'Den')]).text, '只在这个房间使用:Den') + + // The card wires them: the grant row paints the use hint, and a face-to-face room the rows do not + // name comes back under `This room only`. + const view = { grants: [grant], rooms: [room('r1', 'Den'), room('r2', 'Lab'), { id: 'r3', name: 'Hall', origin: 'face-to-face' }] } + const nodes = loadApp(zhWindow, [view]).ManageAccess({ bot }) + const drawn = draw(nodes) + assert.ok(drawn.includes('正在 2 个房间里使用:Den, Lab'), `the row reads: ${drawn.join(' | ')}`) + assert.ok(drawn.includes('只在这个房间使用:Hall'), `the room-only line reads: ${drawn.join(' | ')}`) + assert.equal(findNode(nodes, n => n.props?.title === 'Den\nLab')?.props.title, 'Den\nLab', 'the tooltip is still the whole list') +}) + +test('#3114 cut 26: the invite hint above the link speaks the window’s language', () => { + assert.equal(textOf(loadApp(zhWindow).InviteToBot({ bot }), 'invite-hint-sharing'), '邀请只把 Mine 授权给对方。') + // Revoke is mentioned only once People with access has someone to revoke. + assert.equal(textOf(loadApp(zhWindow).InviteToBot({ bot, revocable: true }), 'invite-hint-sharing'), + '邀请只把 Mine 授权给对方。随时可以在「可访问的人」里撤销。') +}) + +// A host with no translator keeps the English it drew before this change, character for character — +// `tr()` replaces a string only when the host answers for it. +test('#3114 cut 26: a host with no translator keeps today’s English', () => { + const app = loadApp(bareWindow) + assert.equal(app.roomHint('use', [room('r1', 'Den'), room('r2', 'Lab')]).text, 'In use in 2 rooms: Den, Lab') + assert.equal(app.roomHint('only', [room('r1', 'Hall')]).text, 'This room only: Hall') + assert.equal(app.roomHint('use', [room('r1', 'Den'), room('r2', 'Lab'), room('r3', 'Hall'), room('r4', 'Loft')]).text, + 'In use in 4 rooms: Den, Lab, Hall +1 more') + assert.equal(textOf(loadApp(bareWindow).InviteToBot({ bot }), 'invite-hint-sharing'), 'Invite grants Mine only.') + assert.equal(textOf(loadApp(bareWindow).InviteToBot({ bot, revocable: true }), 'invite-hint-sharing'), + 'Invite grants Mine only. Revoke anytime in People with access.') +}) + +// The baselines may only shrink, and an entry leaves when its zh key lands — a draw that is +// translated no longer needs pinning. The files are read as the repository ships them. +const pinned = [ + ['i18n-missing-entries.baseline.json', ['In use in {} room{}: ', 'This room only: ', ' +{} more']], + ['i18n-template-draws.baseline.json', [ + 'Invite grants {} only.', + 'Invite grants {} only. Revoke anytime in People with access.', + ]], +] +const entriesOf = file => JSON.parse(readFileSync(new URL(`../../../core/test/${file}`, import.meta.url), 'utf8')).entries + +test('#3114 cut 26: the two baselines lose these draws and the dictionary gains the keys', () => { + for (const [file, keys] of pinned) { + const entries = entriesOf(file) + const still = keys.map(key => `plugins/social/client.js:${key}`).filter(id => entries.includes(id)) + assert.deepEqual(still, [], `${file.replace('.baseline.json', '')} still pins ${still[0]}`) + } + // The baselines shrink by exactly these draws and nothing else does: the totals are the ratchet's + // numbers, and a later cut that moves them moves these numbers with it. + assert.deepEqual([entriesOf('i18n-plugins.baseline.json').length, entriesOf('i18n-template-draws.baseline.json').length, entriesOf('i18n-missing-entries.baseline.json').length], [12, 12, 48]) + // Every new key is the dictionary's, each answer character for character — the four keys that end + // in a space and the one that starts with it included, so a trimmed copy is caught here. + assert.deepEqual(Object.entries({ + 'Invite grants {bot} only.': '邀请只把 {bot} 授权给对方。', + 'Invite grants {bot} only. Revoke anytime in People with access.': '邀请只把 {bot} 授权给对方。随时可以在「可访问的人」里撤销。', + 'In use in {n} room: ': '正在 {n} 个房间里使用:', + 'In use in {n} rooms: ': '正在 {n} 个房间里使用:', + 'This room only: ': '只在这个房间使用:', + ' +{n} more': ',还有 {n} 个', + }).map(([key]) => [key, zh[key]]), Object.entries({ + 'Invite grants {bot} only.': '邀请只把 {bot} 授权给对方。', + 'Invite grants {bot} only. Revoke anytime in People with access.': '邀请只把 {bot} 授权给对方。随时可以在「可访问的人」里撤销。', + 'In use in {n} room: ': '正在 {n} 个房间里使用:', + 'In use in {n} rooms: ': '正在 {n} 个房间里使用:', + 'This room only: ': '只在这个房间使用:', + ' +{n} more': ',还有 {n} 个', + })) +})