diff --git a/changelog.d/3114-face-join-i18n.fixed.md b/changelog.d/3114-face-join-i18n.fixed.md new file mode 100644 index 000000000..bafd38cd1 --- /dev/null +++ b/changelog.d/3114-face-join-i18n.fixed.md @@ -0,0 +1 @@ +The **Join by number or link** / **Start a face-to-face room** dialog now follows the window's language: the Bot picker, the six-digit field and its refusals, the link and scan rows, their status lines, and every invite and camera refusal a join can hit ([#3114](https://github.com/ThinkFlowLab/FlyBot/issues/3114)). diff --git a/core/client.js b/core/client.js index 681ee8b0f..738f82fc7 100644 --- a/core/client.js +++ b/core/client.js @@ -299,6 +299,45 @@ var ZH = { "Room number {code}": "房间号码 {code}", "QR code for room number {code}": "房间号码 {code} 的二维码", "Scan this with FlyBot to join": "用 FlyBot 扫描加入", + // #3114 cut 24: the join/create a room dialog — the picker's name, the number field and its + // refusals, the link and scan rows, and the copy tables those rows read. + "Enter a 6-digit number.": "请输入 6 位数字。", + "Choose which of your Bots join.": "请选择用哪些 Bot 加入。", + "Joining with that link…": "正在用这条链接加入…", + "Looking up that room…": "正在查找那个房间…", + "This group is already in your sidebar.": "这个群已经在你的侧边栏里了。", + "Point the camera at a FlyBot room code.": "把镜头对准 FlyBot 房间码。", + "Scanned a group link.": "已扫描到群链接。", + "Scanned an invite link.": "已扫描到邀请链接。", + "Scanned {code}.": "已扫描到 {code}。", + "Scanned {code}. Pick a Bot to join.": "已扫描到 {code}。选一个 Bot 加入。", + "Loading your Bots…": "正在加载你的 Bot…", + "Waiting for {who} to let you in. If the group does not appear, press Join group to ask again.": "正在等 {who} 放你进去。如果群没有出现,再按一次「加入群」重新申请。", + "Asked to join {name}. It opens in your sidebar as soon as their FlyBot seats your Bots.": "已申请加入 {name}。对方的 FlyBot 放好你的 Bot 后,群会出现在你的侧边栏。", + "the group": "那个群", + "the group’s owner": "那个群的主人", + "A group on another FlyBot": "另一个 FlyBot 上的群", + "This FlyBot has not approved the request yet, so their group has not been asked.": "这个 FlyBot 还没批准这次申请,所以对方的群还没收到请求。", + "Their FlyBot was not asked. Check the link and try again.": "对方的 FlyBot 没有收到请求。检查链接后再试一次。", + "Could not join that room. Try another number.": "没能加入那个房间。换一个号码试试。", + "Could not join that room with that link.": "没能用那条链接加入那个房间。", + "Invites need a newer Bot Social. The 6-digit number still works.": "邀请需要更新版本的 Bot Social。6 位号码仍然可用。", + "That is not an invite link. It looks like https://…/r/…": "这不是邀请链接。它看起来像 https://…/r/…", + "That link has expired. Ask for a new one.": "这条链接已过期。向他们要一条新的。", + "That link was withdrawn. Ask for a new one.": "这条链接已被撤回。向他们要一条新的。", + "You already joined with that link using other Bots. Leave the group first to join with different ones.": "你已经用别的 Bot 通过这条链接加入过了。想换 Bot 请先退出那个群。", + "That link is for this FlyBot’s own room.": "这条链接是给这个 FlyBot 自己的房间用的。", + "Too many tries for now. Wait a minute and try again.": "尝试次数太多了。等一分钟再试。", + "That link does not open any room. Check that it was copied whole.": "这条链接打不开任何房间。检查一下是否复制完整。", + "Bot Social could not look up that link right now. Try again.": "Bot Social 现在查不了这条链接。请再试一次。", + "That link cannot seat these Bots. Ask for a new one.": "这条链接放不下这些 Bot。向他们要一条新的。", + "That room cannot take guests right now.": "那个房间现在不能接待访客。", + "This FlyBot has no Bot Social identity yet.": "这个 FlyBot 还没有 Bot Social 身份。", + "This browser cannot scan codes. Type the 6-digit number instead.": "这个浏览器不能扫码。请直接输入 6 位号码。", + "This browser cannot use a camera here. Type the 6-digit number instead.": "这个浏览器在这里用不了摄像头。请直接输入 6 位号码。", + "FlyBot cannot use the camera. Allow the camera for this page, or type the 6-digit number instead.": "FlyBot 用不了摄像头。给这个页面开放摄像头权限,或直接输入 6 位号码。", + "That is not a FlyBot room code. Ask for the 6-digit number instead.": "这不是 FlyBot 房间码。向他们要 6 位号码吧。", + "The camera stopped before it read a code. Type the 6-digit number instead.": "摄像头还没读到码就停了。请直接输入 6 位号码。", "Share with a friend": "分享给朋友", "One click shares {name} with someone you already know. No invite link. They can decline; you can Revoke in People with access.": "一键把 {name} 分享给你已经认识的人,不需要邀请链接。对方可以拒绝,你也可以在「可访问的人」里撤销。", "Loading friends…": "正在加载朋友…", diff --git a/core/src/client/i18n.js b/core/src/client/i18n.js index 579e3c962..9f4de4f95 100644 --- a/core/src/client/i18n.js +++ b/core/src/client/i18n.js @@ -266,6 +266,45 @@ const ZH = { 'Room number {code}': '房间号码 {code}', 'QR code for room number {code}': '房间号码 {code} 的二维码', 'Scan this with FlyBot to join': '用 FlyBot 扫描加入', + // #3114 cut 24: the join/create a room dialog — the picker's name, the number field and its + // refusals, the link and scan rows, and the copy tables those rows read. + 'Enter a 6-digit number.': '请输入 6 位数字。', + 'Choose which of your Bots join.': '请选择用哪些 Bot 加入。', + 'Joining with that link…': '正在用这条链接加入…', + 'Looking up that room…': '正在查找那个房间…', + 'This group is already in your sidebar.': '这个群已经在你的侧边栏里了。', + 'Point the camera at a FlyBot room code.': '把镜头对准 FlyBot 房间码。', + 'Scanned a group link.': '已扫描到群链接。', + 'Scanned an invite link.': '已扫描到邀请链接。', + 'Scanned {code}.': '已扫描到 {code}。', + 'Scanned {code}. Pick a Bot to join.': '已扫描到 {code}。选一个 Bot 加入。', + 'Loading your Bots…': '正在加载你的 Bot…', + 'Waiting for {who} to let you in. If the group does not appear, press Join group to ask again.': '正在等 {who} 放你进去。如果群没有出现,再按一次「加入群」重新申请。', + 'Asked to join {name}. It opens in your sidebar as soon as their FlyBot seats your Bots.': '已申请加入 {name}。对方的 FlyBot 放好你的 Bot 后,群会出现在你的侧边栏。', + 'the group': '那个群', + 'the group’s owner': '那个群的主人', + 'A group on another FlyBot': '另一个 FlyBot 上的群', + 'This FlyBot has not approved the request yet, so their group has not been asked.': '这个 FlyBot 还没批准这次申请,所以对方的群还没收到请求。', + 'Their FlyBot was not asked. Check the link and try again.': '对方的 FlyBot 没有收到请求。检查链接后再试一次。', + 'Could not join that room. Try another number.': '没能加入那个房间。换一个号码试试。', + 'Could not join that room with that link.': '没能用那条链接加入那个房间。', + 'Invites need a newer Bot Social. The 6-digit number still works.': '邀请需要更新版本的 Bot Social。6 位号码仍然可用。', + 'That is not an invite link. It looks like https://…/r/…': '这不是邀请链接。它看起来像 https://…/r/…', + 'That link has expired. Ask for a new one.': '这条链接已过期。向他们要一条新的。', + 'That link was withdrawn. Ask for a new one.': '这条链接已被撤回。向他们要一条新的。', + 'You already joined with that link using other Bots. Leave the group first to join with different ones.': '你已经用别的 Bot 通过这条链接加入过了。想换 Bot 请先退出那个群。', + 'That link is for this FlyBot’s own room.': '这条链接是给这个 FlyBot 自己的房间用的。', + 'Too many tries for now. Wait a minute and try again.': '尝试次数太多了。等一分钟再试。', + 'That link does not open any room. Check that it was copied whole.': '这条链接打不开任何房间。检查一下是否复制完整。', + 'Bot Social could not look up that link right now. Try again.': 'Bot Social 现在查不了这条链接。请再试一次。', + 'That link cannot seat these Bots. Ask for a new one.': '这条链接放不下这些 Bot。向他们要一条新的。', + 'That room cannot take guests right now.': '那个房间现在不能接待访客。', + 'This FlyBot has no Bot Social identity yet.': '这个 FlyBot 还没有 Bot Social 身份。', + 'This browser cannot scan codes. Type the 6-digit number instead.': '这个浏览器不能扫码。请直接输入 6 位号码。', + 'This browser cannot use a camera here. Type the 6-digit number instead.': '这个浏览器在这里用不了摄像头。请直接输入 6 位号码。', + 'FlyBot cannot use the camera. Allow the camera for this page, or type the 6-digit number instead.': 'FlyBot 用不了摄像头。给这个页面开放摄像头权限,或直接输入 6 位号码。', + 'That is not a FlyBot room code. Ask for the 6-digit number instead.': '这不是 FlyBot 房间码。向他们要 6 位号码吧。', + 'The camera stopped before it read a code. Type the 6-digit number instead.': '摄像头还没读到码就停了。请直接输入 6 位号码。', 'Share with a friend': '分享给朋友', 'One click shares {name} with someone you already know. No invite link. They can decline; you can Revoke in People with access.': '一键把 {name} 分享给你已经认识的人,不需要邀请链接。对方可以拒绝,你也可以在「可访问的人」里撤销。', 'Loading friends…': '正在加载朋友…', diff --git a/core/test/i18n-missing-entries.baseline.json b/core/test/i18n-missing-entries.baseline.json index 4fc73164a..58632ba1b 100644 --- a/core/test/i18n-missing-entries.baseline.json +++ b/core/test/i18n-missing-entries.baseline.json @@ -3,51 +3,20 @@ "entries": [ "plugins/social/client.js: +{} more", "plugins/social/client.js:Anyone with the link can join while the room is open.", - "plugins/social/client.js:Bot Social could not look up that link right now. Try again.", "plugins/social/client.js:Chat paused", - "plugins/social/client.js:Choose which of your Bots join.", "plugins/social/client.js:Could not reach FlyBot. Check that it is still running.", - "plugins/social/client.js:Enter a 6-digit number.", - "plugins/social/client.js:FlyBot cannot use the camera. Allow the camera for this page, or type the 6-digit number instead.", "plugins/social/client.js:In use in {} room{}: ", - "plugins/social/client.js:Invites need a newer Bot Social. The 6-digit number still works.#1", - "plugins/social/client.js:Invites need a newer Bot Social. The 6-digit number still works.#2", - "plugins/social/client.js:Invites need a newer Bot Social. The 6-digit number still works.#3", - "plugins/social/client.js:Joining with that link…#1", - "plugins/social/client.js:Joining with that link…#2", "plugins/social/client.js:Link ready", - "plugins/social/client.js:Loading your Bots…", - "plugins/social/client.js:Looking up that room…#1", - "plugins/social/client.js:Looking up that room…#2", "plugins/social/client.js:Past rooms", - "plugins/social/client.js:Point the camera at a FlyBot room code.", "plugins/social/client.js:QR code for this room invite", "plugins/social/client.js:Remove this Bot from Friends' Bots and from your groups. This does not unfriend the owner.", "plugins/social/client.js:Scan to open this room", - "plugins/social/client.js:Scanned a group link.", - "plugins/social/client.js:Scanned an invite link.", "plugins/social/client.js:Social is not running: the plugin did not start. See Settings → Feedback.", "plugins/social/client.js:Social#1", "plugins/social/client.js:Social#2", - "plugins/social/client.js:That is not a FlyBot room code. Ask for the 6-digit number instead.", - "plugins/social/client.js:That is not an invite link. It looks like https://…/r/…", - "plugins/social/client.js:That link cannot seat these Bots. Ask for a new one.", - "plugins/social/client.js:That link does not open any room. Check that it was copied whole.", - "plugins/social/client.js:That link has expired. Ask for a new one.", - "plugins/social/client.js:That link is for this FlyBot’s own room.", - "plugins/social/client.js:That link was withdrawn. Ask for a new one.", - "plugins/social/client.js:That room cannot take guests right now.", "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:The camera stopped before it read a code. Type the 6-digit number instead.", - "plugins/social/client.js:This FlyBot has no Bot Social identity yet.", - "plugins/social/client.js:This browser cannot scan codes. Type the 6-digit number instead.", - "plugins/social/client.js:This browser cannot use a camera here. Type the 6-digit number instead.", - "plugins/social/client.js:This group is already in your sidebar.", "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:Too many tries for now. Wait a minute and try again.", - "plugins/social/client.js:You already joined with that link using other Bots. Leave the group first to join with different ones.", - "plugins/social/client.js:the group", "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-missing-entries.test.js b/core/test/i18n-missing-entries.test.js index e139da22f..ddfb4c0bd 100644 --- a/core/test/i18n-missing-entries.test.js +++ b/core/test/i18n-missing-entries.test.js @@ -62,7 +62,7 @@ test('the scan counts copy tables and copy props, not data', () => { "const REFUSAL_COPY = { expired: 'Too late.', busy: 'Wait a moment.' }", "const STATE_TEXT = { connected: t => t('Connected') }", "const INVITE_UNSUPPORTED = 'Invites need a newer Bot Social.'", - "setStatus({ tone: 'error', text: 'Enter a 6-digit number.' })", + "setStatus({ tone: 'error', text: 'Type the 6-digit number.' })", "setInvite({ status: { tone: 'error', text: INVITE_UNSUPPORTED } })", "h('div', { className: 'fs-status', role: status === 'done' ? 'status' : 'note' }, tr('Member'))", "h(QrImage, { text: qrText, kind: 'face-qr', label: 'QR code for this room', hint: 'Scan this to join' })", @@ -72,7 +72,7 @@ test('the scan counts copy tables and copy props, not data', () => { assert.deepEqual(missingCopy(source, 'plugins/sample/client.js').map(entry => entry.key), [ 'Too late.', 'Wait a moment.', - 'Enter a 6-digit number.', + 'Type the 6-digit number.', 'Invites need a newer Bot Social.', 'QR code for this room', 'Scan this to join', diff --git a/core/test/i18n-plugins.baseline.json b/core/test/i18n-plugins.baseline.json index 81e8a6915..45d91db2c 100644 --- a/core/test/i18n-plugins.baseline.json +++ b/core/test/i18n-plugins.baseline.json @@ -6,7 +6,6 @@ "plugins/social/client.js:Copied#2", "plugins/social/client.js:Copy", "plugins/social/client.js:Your Bot Social handle", - "plugins/social/client.js:Your Bots", "plugins/timeline/client.js:Close", "plugins/timeline/client.js:Copied", "plugins/timeline/client.js:Copying…", diff --git a/core/test/i18n-template-draws.baseline.json b/core/test/i18n-template-draws.baseline.json index ed43b08df..cef782aae 100644 --- a/core/test/i18n-template-draws.baseline.json +++ b/core/test/i18n-template-draws.baseline.json @@ -1,14 +1,10 @@ { "version": 1, "entries": [ - "plugins/social/client.js:Asked to join {}. It opens in your sidebar as soon as their FlyBot seats your Bots.", "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:Scanned {}.", - "plugins/social/client.js:Scanned {}. Pick a Bot to join.", - "plugins/social/client.js:Waiting for {} to let you in. If the group does not appear, press Join group to ask again.", "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 7f9f2d4f9..3952b8dc5 100644 --- a/patches/ds-bot/0001-core-fixes.patch +++ b/patches/ds-bot/0001-core-fixes.patch @@ -895,7 +895,7 @@ diff --git a/src/client/i18n.js b/src/client/i18n.js Content: '内容', 'Referenced {labels}': '引用了 {labels}', ', ': '、', -@@ -41,22 +41,158 @@ const ZH = { +@@ -41,22 +41,197 @@ const ZH = { ' and ': '、', and: '和', '{count} members': '{count} 位成员', @@ -989,6 +989,45 @@ diff --git a/src/client/i18n.js b/src/client/i18n.js + 'Room number {code}': '房间号码 {code}', + 'QR code for room number {code}': '房间号码 {code} 的二维码', + 'Scan this with FlyBot to join': '用 FlyBot 扫描加入', ++ // #3114 cut 24: the join/create a room dialog — the picker's name, the number field and its ++ // refusals, the link and scan rows, and the copy tables those rows read. ++ 'Enter a 6-digit number.': '请输入 6 位数字。', ++ 'Choose which of your Bots join.': '请选择用哪些 Bot 加入。', ++ 'Joining with that link…': '正在用这条链接加入…', ++ 'Looking up that room…': '正在查找那个房间…', ++ 'This group is already in your sidebar.': '这个群已经在你的侧边栏里了。', ++ 'Point the camera at a FlyBot room code.': '把镜头对准 FlyBot 房间码。', ++ 'Scanned a group link.': '已扫描到群链接。', ++ 'Scanned an invite link.': '已扫描到邀请链接。', ++ 'Scanned {code}.': '已扫描到 {code}。', ++ 'Scanned {code}. Pick a Bot to join.': '已扫描到 {code}。选一个 Bot 加入。', ++ 'Loading your Bots…': '正在加载你的 Bot…', ++ 'Waiting for {who} to let you in. If the group does not appear, press Join group to ask again.': '正在等 {who} 放你进去。如果群没有出现,再按一次「加入群」重新申请。', ++ 'Asked to join {name}. It opens in your sidebar as soon as their FlyBot seats your Bots.': '已申请加入 {name}。对方的 FlyBot 放好你的 Bot 后,群会出现在你的侧边栏。', ++ 'the group': '那个群', ++ 'the group’s owner': '那个群的主人', ++ 'A group on another FlyBot': '另一个 FlyBot 上的群', ++ 'This FlyBot has not approved the request yet, so their group has not been asked.': '这个 FlyBot 还没批准这次申请,所以对方的群还没收到请求。', ++ 'Their FlyBot was not asked. Check the link and try again.': '对方的 FlyBot 没有收到请求。检查链接后再试一次。', ++ 'Could not join that room. Try another number.': '没能加入那个房间。换一个号码试试。', ++ 'Could not join that room with that link.': '没能用那条链接加入那个房间。', ++ 'Invites need a newer Bot Social. The 6-digit number still works.': '邀请需要更新版本的 Bot Social。6 位号码仍然可用。', ++ 'That is not an invite link. It looks like https://…/r/…': '这不是邀请链接。它看起来像 https://…/r/…', ++ 'That link has expired. Ask for a new one.': '这条链接已过期。向他们要一条新的。', ++ 'That link was withdrawn. Ask for a new one.': '这条链接已被撤回。向他们要一条新的。', ++ 'You already joined with that link using other Bots. Leave the group first to join with different ones.': '你已经用别的 Bot 通过这条链接加入过了。想换 Bot 请先退出那个群。', ++ 'That link is for this FlyBot’s own room.': '这条链接是给这个 FlyBot 自己的房间用的。', ++ 'Too many tries for now. Wait a minute and try again.': '尝试次数太多了。等一分钟再试。', ++ 'That link does not open any room. Check that it was copied whole.': '这条链接打不开任何房间。检查一下是否复制完整。', ++ 'Bot Social could not look up that link right now. Try again.': 'Bot Social 现在查不了这条链接。请再试一次。', ++ 'That link cannot seat these Bots. Ask for a new one.': '这条链接放不下这些 Bot。向他们要一条新的。', ++ 'That room cannot take guests right now.': '那个房间现在不能接待访客。', ++ 'This FlyBot has no Bot Social identity yet.': '这个 FlyBot 还没有 Bot Social 身份。', ++ 'This browser cannot scan codes. Type the 6-digit number instead.': '这个浏览器不能扫码。请直接输入 6 位号码。', ++ 'This browser cannot use a camera here. Type the 6-digit number instead.': '这个浏览器在这里用不了摄像头。请直接输入 6 位号码。', ++ 'FlyBot cannot use the camera. Allow the camera for this page, or type the 6-digit number instead.': 'FlyBot 用不了摄像头。给这个页面开放摄像头权限,或直接输入 6 位号码。', ++ 'That is not a FlyBot room code. Ask for the 6-digit number instead.': '这不是 FlyBot 房间码。向他们要 6 位号码吧。', ++ 'The camera stopped before it read a code. Type the 6-digit number instead.': '摄像头还没读到码就停了。请直接输入 6 位号码。', + 'Share with a friend': '分享给朋友', + 'One click shares {name} with someone you already know. No invite link. They can decline; you can Revoke in People with access.': '一键把 {name} 分享给你已经认识的人,不需要邀请链接。对方可以拒绝,你也可以在「可访问的人」里撤销。', + 'Loading friends…': '正在加载朋友…', diff --git a/patches/ds-bot/0008-client-bundle.patch b/patches/ds-bot/0008-client-bundle.patch index 42284b14e..fb4b5e26f 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,157 @@ var ZH = { +@@ -78,21 +78,196 @@ var ZH = { " and ": "、", and: "和", "{count} members": "{count} 位成员", @@ -253,6 +253,45 @@ diff --git a/client.js b/client.js + "Room number {code}": "房间号码 {code}", + "QR code for room number {code}": "房间号码 {code} 的二维码", + "Scan this with FlyBot to join": "用 FlyBot 扫描加入", ++ // #3114 cut 24: the join/create a room dialog — the picker's name, the number field and its ++ // refusals, the link and scan rows, and the copy tables those rows read. ++ "Enter a 6-digit number.": "请输入 6 位数字。", ++ "Choose which of your Bots join.": "请选择用哪些 Bot 加入。", ++ "Joining with that link…": "正在用这条链接加入…", ++ "Looking up that room…": "正在查找那个房间…", ++ "This group is already in your sidebar.": "这个群已经在你的侧边栏里了。", ++ "Point the camera at a FlyBot room code.": "把镜头对准 FlyBot 房间码。", ++ "Scanned a group link.": "已扫描到群链接。", ++ "Scanned an invite link.": "已扫描到邀请链接。", ++ "Scanned {code}.": "已扫描到 {code}。", ++ "Scanned {code}. Pick a Bot to join.": "已扫描到 {code}。选一个 Bot 加入。", ++ "Loading your Bots…": "正在加载你的 Bot…", ++ "Waiting for {who} to let you in. If the group does not appear, press Join group to ask again.": "正在等 {who} 放你进去。如果群没有出现,再按一次「加入群」重新申请。", ++ "Asked to join {name}. It opens in your sidebar as soon as their FlyBot seats your Bots.": "已申请加入 {name}。对方的 FlyBot 放好你的 Bot 后,群会出现在你的侧边栏。", ++ "the group": "那个群", ++ "the group’s owner": "那个群的主人", ++ "A group on another FlyBot": "另一个 FlyBot 上的群", ++ "This FlyBot has not approved the request yet, so their group has not been asked.": "这个 FlyBot 还没批准这次申请,所以对方的群还没收到请求。", ++ "Their FlyBot was not asked. Check the link and try again.": "对方的 FlyBot 没有收到请求。检查链接后再试一次。", ++ "Could not join that room. Try another number.": "没能加入那个房间。换一个号码试试。", ++ "Could not join that room with that link.": "没能用那条链接加入那个房间。", ++ "Invites need a newer Bot Social. The 6-digit number still works.": "邀请需要更新版本的 Bot Social。6 位号码仍然可用。", ++ "That is not an invite link. It looks like https://…/r/…": "这不是邀请链接。它看起来像 https://…/r/…", ++ "That link has expired. Ask for a new one.": "这条链接已过期。向他们要一条新的。", ++ "That link was withdrawn. Ask for a new one.": "这条链接已被撤回。向他们要一条新的。", ++ "You already joined with that link using other Bots. Leave the group first to join with different ones.": "你已经用别的 Bot 通过这条链接加入过了。想换 Bot 请先退出那个群。", ++ "That link is for this FlyBot’s own room.": "这条链接是给这个 FlyBot 自己的房间用的。", ++ "Too many tries for now. Wait a minute and try again.": "尝试次数太多了。等一分钟再试。", ++ "That link does not open any room. Check that it was copied whole.": "这条链接打不开任何房间。检查一下是否复制完整。", ++ "Bot Social could not look up that link right now. Try again.": "Bot Social 现在查不了这条链接。请再试一次。", ++ "That link cannot seat these Bots. Ask for a new one.": "这条链接放不下这些 Bot。向他们要一条新的。", ++ "That room cannot take guests right now.": "那个房间现在不能接待访客。", ++ "This FlyBot has no Bot Social identity yet.": "这个 FlyBot 还没有 Bot Social 身份。", ++ "This browser cannot scan codes. Type the 6-digit number instead.": "这个浏览器不能扫码。请直接输入 6 位号码。", ++ "This browser cannot use a camera here. Type the 6-digit number instead.": "这个浏览器在这里用不了摄像头。请直接输入 6 位号码。", ++ "FlyBot cannot use the camera. Allow the camera for this page, or type the 6-digit number instead.": "FlyBot 用不了摄像头。给这个页面开放摄像头权限,或直接输入 6 位号码。", ++ "That is not a FlyBot room code. Ask for the 6-digit number instead.": "这不是 FlyBot 房间码。向他们要 6 位号码吧。", ++ "The camera stopped before it read a code. Type the 6-digit number instead.": "摄像头还没读到码就停了。请直接输入 6 位号码。", + "Share with a friend": "分享给朋友", + "One click shares {name} with someone you already know. No invite link. They can decline; you can Revoke in People with access.": "一键把 {name} 分享给你已经认识的人,不需要邀请链接。对方可以拒绝,你也可以在「可访问的人」里撤销。", + "Loading friends…": "正在加载朋友…", 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 4fc73164a..58632ba1b 100644 --- a/patches/ds-bot/files/test/i18n-missing-entries.baseline.json +++ b/patches/ds-bot/files/test/i18n-missing-entries.baseline.json @@ -3,51 +3,20 @@ "entries": [ "plugins/social/client.js: +{} more", "plugins/social/client.js:Anyone with the link can join while the room is open.", - "plugins/social/client.js:Bot Social could not look up that link right now. Try again.", "plugins/social/client.js:Chat paused", - "plugins/social/client.js:Choose which of your Bots join.", "plugins/social/client.js:Could not reach FlyBot. Check that it is still running.", - "plugins/social/client.js:Enter a 6-digit number.", - "plugins/social/client.js:FlyBot cannot use the camera. Allow the camera for this page, or type the 6-digit number instead.", "plugins/social/client.js:In use in {} room{}: ", - "plugins/social/client.js:Invites need a newer Bot Social. The 6-digit number still works.#1", - "plugins/social/client.js:Invites need a newer Bot Social. The 6-digit number still works.#2", - "plugins/social/client.js:Invites need a newer Bot Social. The 6-digit number still works.#3", - "plugins/social/client.js:Joining with that link…#1", - "plugins/social/client.js:Joining with that link…#2", "plugins/social/client.js:Link ready", - "plugins/social/client.js:Loading your Bots…", - "plugins/social/client.js:Looking up that room…#1", - "plugins/social/client.js:Looking up that room…#2", "plugins/social/client.js:Past rooms", - "plugins/social/client.js:Point the camera at a FlyBot room code.", "plugins/social/client.js:QR code for this room invite", "plugins/social/client.js:Remove this Bot from Friends' Bots and from your groups. This does not unfriend the owner.", "plugins/social/client.js:Scan to open this room", - "plugins/social/client.js:Scanned a group link.", - "plugins/social/client.js:Scanned an invite link.", "plugins/social/client.js:Social is not running: the plugin did not start. See Settings → Feedback.", "plugins/social/client.js:Social#1", "plugins/social/client.js:Social#2", - "plugins/social/client.js:That is not a FlyBot room code. Ask for the 6-digit number instead.", - "plugins/social/client.js:That is not an invite link. It looks like https://…/r/…", - "plugins/social/client.js:That link cannot seat these Bots. Ask for a new one.", - "plugins/social/client.js:That link does not open any room. Check that it was copied whole.", - "plugins/social/client.js:That link has expired. Ask for a new one.", - "plugins/social/client.js:That link is for this FlyBot’s own room.", - "plugins/social/client.js:That link was withdrawn. Ask for a new one.", - "plugins/social/client.js:That room cannot take guests right now.", "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:The camera stopped before it read a code. Type the 6-digit number instead.", - "plugins/social/client.js:This FlyBot has no Bot Social identity yet.", - "plugins/social/client.js:This browser cannot scan codes. Type the 6-digit number instead.", - "plugins/social/client.js:This browser cannot use a camera here. Type the 6-digit number instead.", - "plugins/social/client.js:This group is already in your sidebar.", "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:Too many tries for now. Wait a minute and try again.", - "plugins/social/client.js:You already joined with that link using other Bots. Leave the group first to join with different ones.", - "plugins/social/client.js:the group", "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-missing-entries.test.js b/patches/ds-bot/files/test/i18n-missing-entries.test.js index e139da22f..ddfb4c0bd 100644 --- a/patches/ds-bot/files/test/i18n-missing-entries.test.js +++ b/patches/ds-bot/files/test/i18n-missing-entries.test.js @@ -62,7 +62,7 @@ test('the scan counts copy tables and copy props, not data', () => { "const REFUSAL_COPY = { expired: 'Too late.', busy: 'Wait a moment.' }", "const STATE_TEXT = { connected: t => t('Connected') }", "const INVITE_UNSUPPORTED = 'Invites need a newer Bot Social.'", - "setStatus({ tone: 'error', text: 'Enter a 6-digit number.' })", + "setStatus({ tone: 'error', text: 'Type the 6-digit number.' })", "setInvite({ status: { tone: 'error', text: INVITE_UNSUPPORTED } })", "h('div', { className: 'fs-status', role: status === 'done' ? 'status' : 'note' }, tr('Member'))", "h(QrImage, { text: qrText, kind: 'face-qr', label: 'QR code for this room', hint: 'Scan this to join' })", @@ -72,7 +72,7 @@ test('the scan counts copy tables and copy props, not data', () => { assert.deepEqual(missingCopy(source, 'plugins/sample/client.js').map(entry => entry.key), [ 'Too late.', 'Wait a moment.', - 'Enter a 6-digit number.', + 'Type the 6-digit number.', 'Invites need a newer Bot Social.', 'QR code for this room', 'Scan this to join', diff --git a/patches/ds-bot/files/test/i18n-plugins.baseline.json b/patches/ds-bot/files/test/i18n-plugins.baseline.json index 81e8a6915..45d91db2c 100644 --- a/patches/ds-bot/files/test/i18n-plugins.baseline.json +++ b/patches/ds-bot/files/test/i18n-plugins.baseline.json @@ -6,7 +6,6 @@ "plugins/social/client.js:Copied#2", "plugins/social/client.js:Copy", "plugins/social/client.js:Your Bot Social handle", - "plugins/social/client.js:Your Bots", "plugins/timeline/client.js:Close", "plugins/timeline/client.js:Copied", "plugins/timeline/client.js:Copying…", 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 ed43b08df..cef782aae 100644 --- a/patches/ds-bot/files/test/i18n-template-draws.baseline.json +++ b/patches/ds-bot/files/test/i18n-template-draws.baseline.json @@ -1,14 +1,10 @@ { "version": 1, "entries": [ - "plugins/social/client.js:Asked to join {}. It opens in your sidebar as soon as their FlyBot seats your Bots.", "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:Scanned {}.", - "plugins/social/client.js:Scanned {}. Pick a Bot to join.", - "plugins/social/client.js:Waiting for {} to let you in. If the group does not appear, press Join group to ask again.", "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 694f809dd..7aa6063e1 100644 --- a/plugins/social/client.js +++ b/plugins/social/client.js @@ -1039,17 +1039,17 @@ window.__ModuleLoader__.load({ const isoAt = (ms) => (Number.isFinite(Number(ms)) && Number(ms) > 0 ? new Date(Number(ms)).toISOString() : '') // One sentence per way a room link is refused (#876), never the generic "not an invite link". const LOCAL_REFUSAL_COPY = { - expired: 'That link has expired. Ask for a new one.', - revoked: 'That link was withdrawn. Ask for a new one.', + expired: tr('That link has expired. Ask for a new one.'), + revoked: tr('That link was withdrawn. Ask for a new one.'), // A link admits anyone it is given to (#892): this refusal is about this home's own earlier claim. - 'claimed-elsewhere': 'You already joined with that link using other Bots. Leave the group first to join with different ones.', - 'own-invite': 'That link is for this FlyBot\u2019s own room.', - busy: 'Too many tries for now. Wait a minute and try again.', - unknown: 'That link does not open any room. Check that it was copied whole.', - 'lookup-failed': 'Bot Social could not look up that link right now. Try again.', - consumed: 'That link cannot seat these Bots. Ask for a new one.', - 'not-addable': 'That room cannot take guests right now.', - 'no-sender': 'This FlyBot has no Bot Social identity yet.', + 'claimed-elsewhere': tr('You already joined with that link using other Bots. Leave the group first to join with different ones.'), + 'own-invite': tr('That link is for this FlyBot’s own room.'), + busy: tr('Too many tries for now. Wait a minute and try again.'), + unknown: tr('That link does not open any room. Check that it was copied whole.'), + 'lookup-failed': tr('Bot Social could not look up that link right now. Try again.'), + consumed: tr('That link cannot seat these Bots. Ask for a new one.'), + 'not-addable': tr('That room cannot take guests right now.'), + 'no-sender': tr('This FlyBot has no Bot Social identity yet.'), } const localRefusal = (code) => LOCAL_REFUSAL_COPY[String(code ?? '')] ?? LOCAL_REFUSAL_COPY['lookup-failed'] // The preview card names a room the person has not entered (#798). `name` is that room's own @@ -1184,7 +1184,7 @@ window.__ModuleLoader__.load({ disabled: !!busy || (!!invite?.url && live), onClick: mint, }, invite?.url && live ? 'Link ready' : tr('Create link'))), invite?.unsupported - ? h('div', { className: 'fs-hint', 'data-flybot': 'face-invite-unsupported', role: 'status' }, INVITE_UNSUPPORTED) + ? h('div', { className: 'fs-hint', 'data-flybot': 'face-invite-unsupported', role: 'status' }, tr(INVITE_UNSUPPORTED)) : null, invite?.revoked ? h('div', { className: 'fs-hint', 'data-flybot': 'face-invite-revoked', role: 'status' }, tr('The link was withdrawn. Nobody can join with it now.')) @@ -1538,11 +1538,11 @@ window.__ModuleLoader__.load({ event?.preventDefault?.() const digits = String(typed ?? code).replace(/\D/g, '').slice(0, 6) if (digits.length !== 6) { - setStatus({ tone: 'error', text: 'Enter a 6-digit number.' }) + setStatus({ tone: 'error', text: tr('Enter a 6-digit number.') }) return } if (!selected.length) { - setStatus({ tone: 'error', text: 'Choose which of your Bots join.' }) + setStatus({ tone: 'error', text: tr('Choose which of your Bots join.') }) return } setBusy(true) @@ -1581,7 +1581,7 @@ window.__ModuleLoader__.load({ } setFailures(failed) if (!last) { - setStatus({ tone: 'error', text: failed[0]?.text || 'Could not join that room. Try another number.' }) + setStatus({ tone: 'error', text: failed[0]?.text || tr('Could not join that room. Try another number.') }) setBusy(false) return } @@ -1639,12 +1639,12 @@ window.__ModuleLoader__.load({ // per-Bot failure list, and one failure never hides the others. const joinTicket = async (text, ticket) => { if (!selected.length) { - setInvite({ link: text, status: { tone: 'error', text: 'Pick a Bot first.' } }) + setInvite({ link: text, status: { tone: 'error', text: tr('Pick a Bot first.') } }) return } setBusy(true) setFailures([]) - setInvite({ link: text, status: { tone: 'hint', text: 'Joining with that link…' } }) + setInvite({ link: text, status: { tone: 'hint', text: tr('Joining with that link…') } }) try { const mine = [] const joined = [] @@ -1655,7 +1655,7 @@ window.__ModuleLoader__.load({ try { const result = await call('social/face-join-invite', { ticket, botId }) if (result?.unsupported) { - setInvite({ link: text, status: { tone: 'error', text: INVITE_UNSUPPORTED } }) + setInvite({ link: text, status: { tone: 'error', text: tr(INVITE_UNSUPPORTED) } }) return } last = result @@ -1675,7 +1675,7 @@ window.__ModuleLoader__.load({ } setFailures(failed) if (!last) { - setInvite({ link: text, status: { tone: 'error', text: failed[0]?.text || 'Could not join that room with that link.' } }) + setInvite({ link: text, status: { tone: 'error', text: failed[0]?.text || tr('Could not join that room with that link.') } }) return } setInvite({ link: text, status: null }) @@ -1696,7 +1696,7 @@ window.__ModuleLoader__.load({ } const ticket = faceInviteTicket(text) if (!ticket) { - setInvite({ link: text, status: { tone: 'error', text: INVITE_LINK_COPY } }) + setInvite({ link: text, status: { tone: 'error', text: tr(INVITE_LINK_COPY) } }) return } // The card on screen for this ticket already answers the press (#824): asking again would cost @@ -1705,7 +1705,7 @@ window.__ModuleLoader__.load({ if (invite.preview?.ticket === ticket) return setBusy(true) setFailures([]) - setInvite({ link: text, status: { tone: 'hint', text: 'Looking up that room…' } }) + setInvite({ link: text, status: { tone: 'hint', text: tr('Looking up that room…') } }) let seen = null try { seen = await call('social/face-invite-preview', { ticket }) @@ -1717,7 +1717,7 @@ window.__ModuleLoader__.load({ // The invite feature itself is off on that server, so a join would answer the same sentence // and reach no route: the dialog stops here, the way the join path already did (#798). if (seen?.unsupported === true) { - setInvite({ link: text, status: { tone: 'error', text: INVITE_UNSUPPORTED } }) + setInvite({ link: text, status: { tone: 'error', text: tr(INVITE_UNSUPPORTED) } }) return } const card = invitePreview(seen) @@ -1733,7 +1733,7 @@ window.__ModuleLoader__.load({ if (invite.preview?.local && invite.preview.link === text) return setBusy(true) setFailures([]) - setInvite({ link: text, status: { tone: 'hint', text: 'Looking up that room…' } }) + setInvite({ link: text, status: { tone: 'hint', text: tr('Looking up that room…') } }) let seen = null try { seen = (await host('room-invite-preview', { link: text }))?.preview ?? null @@ -1751,29 +1751,29 @@ window.__ModuleLoader__.load({ if (seen?.joined) { // #1176: the room is here however it arrived — a link this home claimed (#899), or the host // adding one of these Bots by add-member. Neither is a knock: no Join card, no claim sent. - setInvite({ link: text, status: { tone: 'hint', text: 'This group is already in your sidebar.' } }) + setInvite({ link: text, status: { tone: 'hint', text: tr('This group is already in your sidebar.') } }) return } if (seen?.claimed) { // #899: a claim with no room here is a knock nobody answered yet: say so, and let Join knock again. - const who = seen.owner || seen.lead || 'the group\u2019s owner' - setInvite({ link: text, status: { tone: 'hint', text: `Waiting for ${who} to let you in. If the group does not appear, press Join group to ask again.` }, preview: { ...(card ?? { name: 'A group on another FlyBot', lead: '', people: '', expiresAt: '', clockOffsetMs: 0 }), local: true, link: text } }) + const who = seen.owner || seen.lead || tr('the group’s owner') + setInvite({ link: text, status: { tone: 'hint', text: tr('Waiting for {who} to let you in. If the group does not appear, press Join group to ask again.', { who }) }, preview: { ...(card ?? { name: tr('A group on another FlyBot'), lead: '', people: '', expiresAt: '', clockOffsetMs: 0 }), local: true, link: text } }) return } if (!card) { // An older server has no record to read: the friend's knock is still the way in. - setInvite({ link: text, status: null, preview: { name: 'A group on another FlyBot', lead: '', people: '', expiresAt: '', clockOffsetMs: 0, local: true, link: text } }) + setInvite({ link: text, status: null, preview: { name: tr('A group on another FlyBot'), lead: '', people: '', expiresAt: '', clockOffsetMs: 0, local: true, link: text } }) return } setInvite({ link: text, status: null, preview: { ...card, local: true, link: text } }) } const joinLocal = async (text) => { if (!selected.length) { - setInvite(current => ({ ...current, status: { tone: 'error', text: 'Pick a Bot first.' } })) + setInvite(current => ({ ...current, status: { tone: 'error', text: tr('Pick a Bot first.') } })) return } setBusy(true) - setInvite(current => ({ ...current, status: { tone: 'hint', text: 'Joining with that link…' } })) + setInvite(current => ({ ...current, status: { tone: 'hint', text: tr('Joining with that link…') } })) try { const result = await host('room-invite-ask', { link: text, accept: true, bots: selected }) if (result?.refused) { @@ -1789,21 +1789,22 @@ window.__ModuleLoader__.load({ status: { tone: 'error', text: sent === 'hold' - ? 'This FlyBot has not approved the request yet, so their group has not been asked.' - : 'Their FlyBot was not asked. Check the link and try again.', + ? tr('This FlyBot has not approved the request yet, so their group has not been asked.') + : tr('Their FlyBot was not asked. Check the link and try again.'), }, }) return } - const name = invite.preview?.name && invite.preview.name !== 'A group on another FlyBot' ? `"${invite.preview.name}"` : 'the group' - setInvite({ link: '', status: { tone: 'ok', text: `Asked to join ${name}. It opens in your sidebar as soon as their FlyBot seats your Bots.` } }) + // The placeholder name is drawn translated, so the comparison asks for the same translation. + const name = invite.preview?.name && invite.preview.name !== tr('A group on another FlyBot') ? `"${invite.preview.name}"` : tr('the group') + setInvite({ link: '', status: { tone: 'ok', text: tr('Asked to join {name}. It opens in your sidebar as soon as their FlyBot seats your Bots.', { name }) } }) } catch (e) { setInvite({ link: text, status: { tone: 'error', text: errorText(e) } }) } finally { setBusy(false) } } // One sentence per way a scan can fail, and the number field is untouched either way. const beginScan = () => { - setScan({ tone: 'hint', text: 'Point the camera at a FlyBot room code.' }) + setScan({ tone: 'hint', text: tr('Point the camera at a FlyBot room code.') }) startFaceScan((result) => { if (result?.fail) { setScan({ tone: 'error', text: FACE_SCAN_COPY[result.fail] ?? FACE_SCAN_COPY.camera }) @@ -1811,12 +1812,12 @@ window.__ModuleLoader__.load({ } const raw = String(result?.raw ?? '') if (localInviteHandle(raw)) { - setScan({ tone: 'ok', text: 'Scanned a group link.' }) + setScan({ tone: 'ok', text: tr('Scanned a group link.') }) void previewLocal(raw) return } if (faceInviteTicket(raw)) { - setScan({ tone: 'ok', text: 'Scanned an invite link.' }) + setScan({ tone: 'ok', text: tr('Scanned an invite link.') }) void previewLink(raw) return } @@ -1826,9 +1827,9 @@ window.__ModuleLoader__.load({ return } setCode(digits) - setScan({ tone: 'ok', text: `Scanned ${digits}.` }) + setScan({ tone: 'ok', text: tr('Scanned {code}.', { code: digits }) }) if (selected.length) void join(null, { code: digits }) - else setStatus({ tone: 'hint', text: `Scanned ${digits}. Pick a Bot to join.` }) + else setStatus({ tone: 'hint', text: tr('Scanned {code}. Pick a Bot to join.', { code: digits }) }) }) } const members = room?.members ?? [] @@ -1889,7 +1890,7 @@ window.__ModuleLoader__.load({ }, tr('Enter chat')), }))) : h('form', { onSubmit: join, 'data-flybot': 'face-join' }, h('div', { className: 'fs-hint', 'data-flybot': 'face-join-about' }, tr(starting ? START_FACE_ABOUT : JOIN_OR_CREATE_ABOUT)), - h('ul', { className: 'fs-tiles fs-pick', 'data-flybot': 'face-pick', 'aria-label': 'Your Bots' }, + h('ul', { className: 'fs-tiles fs-pick', 'data-flybot': 'face-pick', 'aria-label': tr('Your Bots') }, bots.map(bot => h(FaceTile, { key: bot.id, bot: faceLook({ roster, local: bot }), @@ -1898,7 +1899,7 @@ window.__ModuleLoader__.load({ selected: selected.includes(bot.id), onToggle: () => toggle(bot.id), }))), - bots.length === 0 ? h('div', { className: 'fs-hint' }, 'Loading your Bots…') : null, + bots.length === 0 ? h('div', { className: 'fs-hint' }, tr('Loading your Bots…')) : null, h('div', { className: 'fs-hint', 'data-flybot': 'face-join-room' }, tr('Room-only: friends do not see these Bots unless you invite them.')), h('div', { className: 'fs-line' }, @@ -2934,11 +2935,11 @@ window.__ModuleLoader__.load({ // No camera, no platform decoder, or a camera the owner refused: one sentence each, and // typing the number keeps working. FlyBot never decodes pixels itself. const FACE_SCAN_COPY = { - 'no-detector': 'This browser cannot scan codes. Type the 6-digit number instead.', - 'no-camera': 'This browser cannot use a camera here. Type the 6-digit number instead.', - denied: 'FlyBot cannot use the camera. Allow the camera for this page, or type the 6-digit number instead.', - foreign: 'That is not a FlyBot room code. Ask for the 6-digit number instead.', - camera: 'The camera stopped before it read a code. Type the 6-digit number instead.', + 'no-detector': tr('This browser cannot scan codes. Type the 6-digit number instead.'), + 'no-camera': tr('This browser cannot use a camera here. Type the 6-digit number instead.'), + denied: tr('FlyBot cannot use the camera. Allow the camera for this page, or type the 6-digit number instead.'), + foreign: tr('That is not a FlyBot room code. Ask for the 6-digit number instead.'), + camera: tr('The camera stopped before it read a code. Type the 6-digit number instead.'), } const faceScanSupport = () => { if (typeof globalThis.BarcodeDetector !== 'function') return 'no-detector' diff --git a/plugins/social/test/add-friend-i18n.test.js b/plugins/social/test/add-friend-i18n.test.js index 37fa1677d..089db9dc9 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], [14, 18, 86]) + assert.deepEqual([entriesOf('i18n-plugins.baseline.json').length, entriesOf('i18n-template-draws.baseline.json').length, entriesOf('i18n-missing-entries.baseline.json').length], [13, 14, 55]) // 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/face-join-i18n.test.js b/plugins/social/test/face-join-i18n.test.js new file mode 100644 index 000000000..70ce1c371 --- /dev/null +++ b/plugins/social/test/face-join-i18n.test.js @@ -0,0 +1,176 @@ +// #3114 cut 24: the join/create a room dialog — the Bot picker's name, the six-digit field and its +// two refusals, the link row and the scan row, the `nobody` step's way out, and the copy tables the +// dialog reads (invite refusals, scan failures, an older Bot Social) — drew English in a zh window. +// A zh window reads the dictionary's words, a host with no translator keeps today's English word +// for word, and the three baselines lose these pins. +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 +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 dialog keeps its state in eleven hook slots, answered in this order: step, bots, selected, +// code, busy, status, failures, room, tick, scan, invite. A setter records what the dialog would +// have drawn next, so a refusal a click produces is read without a browser. +function loadApp(flybot, states = []) { + const registered = [] + const sandbox = { window: { __ModuleLoader__: { load: entry => registered.push(entry) } }, console, setTimeout, clearTimeout } + sandbox.globalThis = sandbox + sandbox.__flybot__ = flybot + runInNewContext(readFileSync(new URL('../client.js', import.meta.url), 'utf8'), sandbox) + const written = [] + let seed = 0 + const app = registered[0].factory(() => ({ + createElement: (type, props, ...children) => ({ type, props: props ?? {}, children: children.flat(Infinity) }), + Fragment: 'F', useEffect() {}, useRef: value => ({ current: value }), + useState: value => [seed < states.length ? states[seed++] : value, next => written.push(typeof next === 'function' ? next(value) : next)], + })) + return { app, written } +} +function walk(node, all = []) { + if (!node || typeof node !== 'object') return all + if (typeof node.type === 'function') return walk(node.type(node.props), all) + all.push(node) + for (const child of node.children ?? []) walk(child, all) + return all +} +const textsOf = nodes => nodes.flatMap(node => (node.children ?? []).filter(child => typeof child === 'string')) +const byId = (nodes, id) => nodes.find(node => node.props?.['data-flybot'] === id) +const BOT = { id: 'b1', name: 'Chief', handle: '@chief.home', isMain: true } +const props = { mode: 'join', roster: { byId: {}, readOnly: '' }, remoteChats: [], actions: {}, onClose: () => {} } +const seed = ({ bots = [], selected = ['b1'], code = '', invite = { link: '', status: null }, status = null, scan = null, room = null, step = 'setup' } = {}) => + [step, bots, selected, code, false, status, [], room, 0, scan, invite] +const open = (flybot, more = {}) => { + const ui = loadApp(flybot, seed(more)) + return { ...ui, nodes: walk(ui.app.FaceToFaceGroup(props)) } +} + +test('#3114 cut 24: the join dialog speaks the window’s language', () => { + const { nodes } = open(zhWindow) + assert.equal(byId(nodes, 'face-pick').props['aria-label'], '你的 Bot', 'the Bot picker’s name is still English') + assert.ok(!textsOf(nodes).includes('Loading your Bots…'), 'the English "Loading your Bots…" is still drawn') + assert.ok(textsOf(nodes).includes('正在加载你的 Bot…') || textsOf(nodes).includes('正在加载你的 Bot…'), 'the loading line follows the window') + assert.equal(nodes.find(node => node.type === 'input' && node.props.maxLength === 6)?.props.placeholder, '6 位数字') +}) + +test('#3114 cut 24: what a press refuses is said in the window’s language', () => { + // Six digits with no Bot picked: the submit answers about the picker, not the number. + const pick = open(zhWindow, { bots: [BOT], selected: [], code: '482913' }) + pick.app.FaceToFaceGroup(props) + const form = pick.nodes.find(node => node.type === 'form') + form.props.onSubmit({ preventDefault() {} }) + assert.deepEqual(pick.written.map(v => v?.text ?? v?.status?.text).filter(Boolean), ['请选择用哪些 Bot 加入。']) + // A short number is refused in the window too. + const short = open(zhWindow, { bots: [BOT], selected: ['b1'], code: '12' }) + short.nodes.find(node => node.type === 'form').props.onSubmit({ preventDefault() {} }) + assert.deepEqual(short.written.map(v => v?.text ?? v?.status?.text).filter(Boolean), ['请输入 6 位数字。']) + // A paste that is not an invite link, and a browser that cannot scan, answer in the window. + const link = open(zhWindow, { bots: [BOT], invite: { link: 'https://social.example/nope', status: null } }) + byId(link.nodes, 'face-link-join-go').props.onClick() + assert.deepEqual(link.written.map(v => v?.text ?? v?.status?.text).filter(Boolean), ['这不是邀请链接。它看起来像 https://…/r/…']) + const scan = open(zhWindow, { bots: [BOT] }) + byId(scan.nodes, 'face-scan').props.onClick() + assert.deepEqual(scan.written.map(v => v?.text ?? v?.status?.text).filter(Boolean), ['把镜头对准 FlyBot 房间码。', '这个浏览器不能扫码。请直接输入 6 位号码。']) +}) + +test('#3114 cut 24: no translator keeps today’s English in the join dialog', () => { + const { nodes } = open(bareWindow) + assert.equal(byId(nodes, 'face-pick').props['aria-label'], 'Your Bots') + assert.ok(textsOf(nodes).includes('Loading your Bots…')) + const pick = open(bareWindow, { bots: [BOT], selected: [], code: '482913' }) + pick.nodes.find(node => node.type === 'form').props.onSubmit({ preventDefault() {} }) + assert.deepEqual(pick.written.map(v => v?.text ?? v?.status?.text).filter(Boolean), ['Choose which of your Bots join.']) + const scan = open(bareWindow, { bots: [BOT] }) + byId(scan.nodes, 'face-scan').props.onClick() + assert.deepEqual(scan.written.map(v => v?.text ?? v?.status?.text).filter(Boolean), ['Point the camera at a FlyBot room code.', 'This browser cannot scan codes. Type the 6-digit number instead.']) +}) + +// The baselines may only shrink, and a pin leaves when its draw goes through `tr()`. +const MISSING_PINS = [ + 'Enter a 6-digit number.', 'Choose which of your Bots join.', + 'Joining with that link…#1', 'Joining with that link…#2', + 'Looking up that room…#1', 'Looking up that room…#2', + 'This group is already in your sidebar.', 'Point the camera at a FlyBot room code.', + 'Scanned a group link.', 'Scanned an invite link.', 'Loading your Bots…', + 'Invites need a newer Bot Social. The 6-digit number still works.#1', + 'Invites need a newer Bot Social. The 6-digit number still works.#2', + 'Invites need a newer Bot Social. The 6-digit number still works.#3', + 'That is not an invite link. It looks like https://…/r/…', + 'That link has expired. Ask for a new one.', 'That link was withdrawn. Ask for a new one.', + 'You already joined with that link using other Bots. Leave the group first to join with different ones.', + 'That link is for this FlyBot’s own room.', 'Too many tries for now. Wait a minute and try again.', + 'That link does not open any room. Check that it was copied whole.', + 'Bot Social could not look up that link right now. Try again.', + 'That link cannot seat these Bots. Ask for a new one.', + 'That room cannot take guests right now.', 'This FlyBot has no Bot Social identity yet.', + 'This browser cannot scan codes. Type the 6-digit number instead.', + 'This browser cannot use a camera here. Type the 6-digit number instead.', + 'FlyBot cannot use the camera. Allow the camera for this page, or type the 6-digit number instead.', + 'That is not a FlyBot room code. Ask for the 6-digit number instead.', + 'The camera stopped before it read a code. Type the 6-digit number instead.', +] +const TEMPLATE_PINS = [ + 'Asked to join {}. It opens in your sidebar as soon as their FlyBot seats your Bots.', + 'Scanned {}.', 'Scanned {}. Pick a Bot to join.', + 'Waiting for {} to let you in. If the group does not appear, press Join group to ask again.', +] +const entriesOf = file => JSON.parse(readFileSync(new URL(`../../../core/test/${file}`, import.meta.url), 'utf8')).entries +test('#3114 cut 24: the baselines lose these draws and the dictionary gains the keys', () => { + const pinned = entriesOf('i18n-missing-entries.baseline.json') + const still = MISSING_PINS.map(key => `plugins/social/client.js:${key}`).filter(id => pinned.includes(id)) + assert.deepEqual(still, [], `i18n-missing-entries still pins ${still.join(', ')}`) + const templates = TEMPLATE_PINS.map(key => `plugins/social/client.js:${key}`).filter(id => entriesOf('i18n-template-draws.baseline.json').includes(id)) + assert.deepEqual(templates, [], `i18n-template-draws still pins ${templates.join(', ')}`) + assert.deepEqual(entriesOf('i18n-plugins.baseline.json').filter(id => id === 'plugins/social/client.js:Your Bots'), [], 'the bare-draw baseline still pins Your Bots') + + // The English is today's English, verbatim: a key renamed on one side only is a red test. + const added = { + 'Enter a 6-digit number.': '请输入 6 位数字。', + 'Choose which of your Bots join.': '请选择用哪些 Bot 加入。', + 'Joining with that link…': '正在用这条链接加入…', + 'Looking up that room…': '正在查找那个房间…', + 'This group is already in your sidebar.': '这个群已经在你的侧边栏里了。', + 'Point the camera at a FlyBot room code.': '把镜头对准 FlyBot 房间码。', + 'Scanned a group link.': '已扫描到群链接。', + 'Scanned an invite link.': '已扫描到邀请链接。', + 'Loading your Bots…': '正在加载你的 Bot…', + 'Scanned {code}.': '已扫描到 {code}。', + 'Scanned {code}. Pick a Bot to join.': '已扫描到 {code}。选一个 Bot 加入。', + 'Waiting for {who} to let you in. If the group does not appear, press Join group to ask again.': '正在等 {who} 放你进去。如果群没有出现,再按一次「加入群」重新申请。', + 'Asked to join {name}. It opens in your sidebar as soon as their FlyBot seats your Bots.': '已申请加入 {name}。对方的 FlyBot 放好你的 Bot 后,群会出现在你的侧边栏。', + 'the group': '那个群', + 'the group’s owner': '那个群的主人', + 'This FlyBot has not approved the request yet, so their group has not been asked.': '这个 FlyBot 还没批准这次申请,所以对方的群还没收到请求。', + 'Their FlyBot was not asked. Check the link and try again.': '对方的 FlyBot 没有收到请求。检查链接后再试一次。', + 'Could not join that room. Try another number.': '没能加入那个房间。换一个号码试试。', + 'Could not join that room with that link.': '没能用那条链接加入那个房间。', + 'A group on another FlyBot': '另一个 FlyBot 上的群', + 'Invites need a newer Bot Social. The 6-digit number still works.': '邀请需要更新版本的 Bot Social。6 位号码仍然可用。', + 'That is not an invite link. It looks like https://…/r/…': '这不是邀请链接。它看起来像 https://…/r/…', + 'That link has expired. Ask for a new one.': '这条链接已过期。向他们要一条新的。', + 'That link was withdrawn. Ask for a new one.': '这条链接已被撤回。向他们要一条新的。', + 'You already joined with that link using other Bots. Leave the group first to join with different ones.': '你已经用别的 Bot 通过这条链接加入过了。想换 Bot 请先退出那个群。', + 'That link is for this FlyBot’s own room.': '这条链接是给这个 FlyBot 自己的房间用的。', + 'Too many tries for now. Wait a minute and try again.': '尝试次数太多了。等一分钟再试。', + 'That link does not open any room. Check that it was copied whole.': '这条链接打不开任何房间。检查一下是否复制完整。', + 'Bot Social could not look up that link right now. Try again.': 'Bot Social 现在查不了这条链接。请再试一次。', + 'That link cannot seat these Bots. Ask for a new one.': '这条链接放不下这些 Bot。向他们要一条新的。', + 'That room cannot take guests right now.': '那个房间现在不能接待访客。', + 'This FlyBot has no Bot Social identity yet.': '这个 FlyBot 还没有 Bot Social 身份。', + 'This browser cannot scan codes. Type the 6-digit number instead.': '这个浏览器不能扫码。请直接输入 6 位号码。', + 'This browser cannot use a camera here. Type the 6-digit number instead.': '这个浏览器在这里用不了摄像头。请直接输入 6 位号码。', + 'FlyBot cannot use the camera. Allow the camera for this page, or type the 6-digit number instead.': 'FlyBot 用不了摄像头。给这个页面开放摄像头权限,或直接输入 6 位号码。', + 'That is not a FlyBot room code. Ask for the 6-digit number instead.': '这不是 FlyBot 房间码。向他们要 6 位号码吧。', + 'The camera stopped before it read a code. Type the 6-digit number instead.': '摄像头还没读到码就停了。请直接输入 6 位号码。', + } + for (const [key, value] of Object.entries(added)) assert.equal(zh[key], value, `the dictionary carries ${key}`) + assert.equal(zh['Your Bots'], '你的 Bot', 'the picker’s name reuses the entry it already has') +}) diff --git a/plugins/social/test/friend-settings-i18n.test.js b/plugins/social/test/friend-settings-i18n.test.js index 34af295d7..dd51b65c0 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, - ], [14, 18, 86]) + ], [13, 14, 55]) // 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/invite-joined.test.js b/plugins/social/test/invite-joined.test.js index de7bd436b..bce0828c0 100644 --- a/plugins/social/test/invite-joined.test.js +++ b/plugins/social/test/invite-joined.test.js @@ -47,6 +47,7 @@ test('#1176: a claim with no room here still waits, so the Join button stays', ( const body = bodyOf('previewLocal') const claimed = body.indexOf('if (seen?.claimed) {') const branch = body.slice(claimed, body.indexOf('\n }', claimed) + 1) - assert.match(branch, /Waiting for \$\{who\} to let you in/) + // The sentence is a dictionary key with a named `{who}` hole (#3114 cut 24), not a `${}` template. + assert.match(branch, /Waiting for \{who\} to let you in\./) assert.match(branch, /preview: \{/, 'the card stays for a knock nobody answered yet') }) diff --git a/plugins/social/test/sharing-page-i18n.test.js b/plugins/social/test/sharing-page-i18n.test.js index 849fb3738..66208fad6 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], [14, 18, 86]) + assert.deepEqual([entriesOf('i18n-plugins.baseline.json').length, entriesOf('i18n-template-draws.baseline.json').length, entriesOf('i18n-missing-entries.baseline.json').length], [13, 14, 55]) // 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.