diff --git a/src/Rooms.ts b/src/Rooms.ts
index 8f08594458..9bb43c3d8c 100644
--- a/src/Rooms.ts
+++ b/src/Rooms.ts
@@ -161,10 +161,16 @@ function guessDMRoomTargetId(room: Room, myUserId: string): string {
export function spaceContextDetailsText(space: Room): string {
if (!space.isSpaceRoom()) return undefined;
- const [parent, ...otherParents] = SpaceStore.instance.getKnownParents(space.roomId);
- if (parent) {
+ const [parent, secondParent, ...otherParents] = SpaceStore.instance.getKnownParents(space.roomId);
+ if (secondParent && !otherParents?.length) {
+ // exactly 2 edge case for improved i18n
+ return _t("%(space1Name)s and %(space2Name)s", {
+ space1Name: space.client.getRoom(parent)?.name,
+ space2Name: space.client.getRoom(secondParent)?.name,
+ });
+ } else if (parent) {
return _t("%(spaceName)s and %(count)s others", {
- spaceName: space.client.getRoom(parent).name,
+ spaceName: space.client.getRoom(parent)?.name,
count: otherParents.length,
});
}
@@ -180,10 +186,16 @@ export function roomContextDetailsText(room: Room): string {
return dmPartner;
}
- const [parent, ...otherParents] = SpaceStore.instance.getKnownParents(room.roomId);
- if (parent) {
+ const [parent, secondParent, ...otherParents] = SpaceStore.instance.getKnownParents(room.roomId);
+ if (secondParent && !otherParents?.length) {
+ // exactly 2 edge case for improved i18n
+ return _t("%(space1Name)s and %(space2Name)s", {
+ space1Name: room.client.getRoom(parent)?.name,
+ space2Name: room.client.getRoom(secondParent)?.name,
+ });
+ } else if (parent) {
return _t("%(spaceName)s and %(count)s others", {
- spaceName: room.client.getRoom(parent).name,
+ spaceName: room.client.getRoom(parent)?.name,
count: otherParents.length,
});
}
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index 40bf22704c..3432643d4b 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -399,6 +399,7 @@
"Failed to invite users to the room:": "Failed to invite users to the room:",
"We sent the others, but the below people couldn't be invited to ": "We sent the others, but the below people couldn't be invited to ",
"Some invites couldn't be sent": "Some invites couldn't be sent",
+ "%(space1Name)s and %(space2Name)s": "%(space1Name)s and %(space2Name)s",
"%(spaceName)s and %(count)s others|other": "%(spaceName)s and %(count)s others",
"%(spaceName)s and %(count)s others|zero": "%(spaceName)s",
"%(spaceName)s and %(count)s others|one": "%(spaceName)s and %(count)s other",