From dfdbb6bed305f8c5f6d6e834d2369c57450b0103 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 4 Feb 2022 12:37:32 +0000 Subject: [PATCH] Make more strings either space/room specific or more ambiguous if unknown --- src/RoomInvite.tsx | 2 +- src/components/views/right_panel/UserInfo.tsx | 3 +- src/i18n/strings/en_EN.json | 18 +++++++---- src/stores/RoomViewStore.tsx | 16 +++++----- src/utils/MultiInviter.ts | 32 +++++++++++++++---- 5 files changed, 46 insertions(+), 25 deletions(-) diff --git a/src/RoomInvite.tsx b/src/RoomInvite.tsx index fae3f5dfebf..8d022eb36e2 100644 --- a/src/RoomInvite.tsx +++ b/src/RoomInvite.tsx @@ -125,7 +125,7 @@ export function showAnyInviteErrors( // user. This usually means that no other users were attempted, making it // pointless for us to list who failed exactly. Modal.createTrackedDialog('Failed to invite users to the room', '', ErrorDialog, { - title: _t("Failed to invite users to the room:", { roomName: room.name }), + title: _t("Failed to invite users to %(roomName)s", { roomName: room.name }), description: inviter.getErrorText(failedUsers[0]), }); return false; diff --git a/src/components/views/right_panel/UserInfo.tsx b/src/components/views/right_panel/UserInfo.tsx index 2aa90460563..61f6ffcf850 100644 --- a/src/components/views/right_panel/UserInfo.tsx +++ b/src/components/views/right_panel/UserInfo.tsx @@ -428,8 +428,7 @@ const UserOptionsSection: React.FC<{ const roomId = member && member.roomId ? member.roomId : RoomViewStore.getRoomId(); const onInviteUserButton = async (ev: ButtonEvent) => { try { - // We use a MultiInviter to re-use the invite logic, even though - // we're only inviting one user. + // We use a MultiInviter to re-use the invite logic, even though we're only inviting one user. const inviter = new MultiInviter(roomId); await inviter.invite([member.userId]).then(() => { if (inviter.getCompletionState(member.userId) !== "invited") { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 6d6699045c3..abbca1922cc 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -384,7 +384,7 @@ "Custom (%(level)s)": "Custom (%(level)s)", "Failed to invite": "Failed to invite", "Operation failed": "Operation failed", - "Failed to invite users to the room:": "Failed to invite users to the room:", + "Failed to invite users to %(roomName)s": "Failed to invite users to %(roomName)s", "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", @@ -694,12 +694,16 @@ "This room is used for important messages from the Homeserver, so you cannot leave it.": "This room is used for important messages from the Homeserver, so you cannot leave it.", "Error leaving room": "Error leaving room", "Unrecognised address": "Unrecognised address", + "You do not have permission to invite people to this space.": "You do not have permission to invite people to this space.", "You do not have permission to invite people to this room.": "You do not have permission to invite people to this room.", - "User %(userId)s is already invited to the room": "User %(userId)s is already invited to the room", - "User %(userId)s is already in the room": "User %(userId)s is already in the room", - "User %(user_id)s does not exist": "User %(user_id)s does not exist", - "User %(user_id)s may or may not exist": "User %(user_id)s may or may not exist", + "User is already invited to the space": "User is already invited to the space", + "User is already invited to the room": "User is already invited to the room", + "User is already in the space": "User is already in the space", + "User is already in the room": "User is already in the room", + "User does not exist": "User does not exist", + "User may or may not exist": "User may or may not exist", "The user must be unbanned before they can be invited.": "The user must be unbanned before they can be invited.", + "The user's homeserver does not support the version of the space.": "The user's homeserver does not support the version of the space.", "The user's homeserver does not support the version of the room.": "The user's homeserver does not support the version of the room.", "Unknown server error": "Unknown server error", "Use a few words, avoid common phrases": "Use a few words, avoid common phrases", @@ -813,12 +817,12 @@ "Update %(brand)s": "Update %(brand)s", "New version of %(brand)s is available": "New version of %(brand)s is available", "Guest": "Guest", - "There was an error joining the room": "There was an error joining the room", + "There was an error joining.": "There was an error joining.", "Sorry, your homeserver is too old to participate in this room.": "Sorry, your homeserver is too old to participate in this room.", "Please contact your homeserver administrator.": "Please contact your homeserver administrator.", "The person who invited you already left the room.": "The person who invited you already left the room.", "The person who invited you already left the room, or their server is offline.": "The person who invited you already left the room, or their server is offline.", - "Failed to join room": "Failed to join room", + "Failed to join": "Failed to join", "All rooms": "All rooms", "Home": "Home", "Favourites": "Favourites", diff --git a/src/stores/RoomViewStore.tsx b/src/stores/RoomViewStore.tsx index 90ba1f88442..cb319433b10 100644 --- a/src/stores/RoomViewStore.tsx +++ b/src/stores/RoomViewStore.tsx @@ -379,13 +379,13 @@ class RoomViewStore extends Store { } public showJoinRoomError(err: MatrixError, roomId: string) { - let msg: ReactNode = err.message ? err.message : JSON.stringify(err); - logger.log("Failed to join room:", msg); + let description: ReactNode = err.message ? err.message : JSON.stringify(err); + logger.log("Failed to join room:", description); if (err.name === "ConnectionError") { - msg = _t("There was an error joining the room"); + description = _t("There was an error joining."); } else if (err.errcode === 'M_INCOMPATIBLE_ROOM_VERSION') { - msg =
+ description =
{ _t("Sorry, your homeserver is too old to participate in this room.") }
{ _t("Please contact your homeserver administrator.") }
; @@ -395,9 +395,9 @@ class RoomViewStore extends Store { if (invitingUserId) { // if the inviting user is on the same HS, there can only be one cause: they left. if (invitingUserId.endsWith(`:${MatrixClientPeg.get().getDomain()}`)) { - msg = _t("The person who invited you already left the room."); + description = _t("The person who invited you already left the room."); } else { - msg = _t("The person who invited you already left the room, or their server is offline."); + description = _t("The person who invited you already left the room, or their server is offline."); } } } @@ -405,8 +405,8 @@ class RoomViewStore extends Store { // FIXME: Using an import will result in test failures const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); Modal.createTrackedDialog('Failed to join room', '', ErrorDialog, { - title: _t("Failed to join room"), - description: msg, + title: _t("Failed to join"), + description, }); } diff --git a/src/utils/MultiInviter.ts b/src/utils/MultiInviter.ts index d3083f2c41d..9916916f8c7 100644 --- a/src/utils/MultiInviter.ts +++ b/src/utils/MultiInviter.ts @@ -203,18 +203,32 @@ export default class MultiInviter { logger.error(err); - let errorText; + const isSpace = this.roomId && this.matrixClient.getRoom(this.roomId)?.isSpaceRoom(); + + let errorText: string; let fatal = false; switch (err.errcode) { case "M_FORBIDDEN": - errorText = _t('You do not have permission to invite people to this room.'); + if (isSpace) { + errorText = _t('You do not have permission to invite people to this space.'); + } else { + errorText = _t('You do not have permission to invite people to this room.'); + } fatal = true; break; case USER_ALREADY_INVITED: - errorText = _t("User %(userId)s is already invited to the room", { userId: address }); + if (isSpace) { + errorText = _t("User is already invited to the space"); + } else { + errorText = _t("User is already invited to the room"); + } break; case USER_ALREADY_JOINED: - errorText = _t("User %(userId)s is already in the room", { userId: address }); + if (isSpace) { + errorText = _t("User is already in the space"); + } else { + errorText = _t("User is already in the room"); + } break; case "M_LIMIT_EXCEEDED": // we're being throttled so wait a bit & try again @@ -224,10 +238,10 @@ export default class MultiInviter { return; case "M_NOT_FOUND": case "M_USER_NOT_FOUND": - errorText = _t("User %(user_id)s does not exist", { user_id: address }); + errorText = _t("User does not exist"); break; case "M_PROFILE_UNDISCLOSED": - errorText = _t("User %(user_id)s may or may not exist", { user_id: address }); + errorText = _t("User may or may not exist"); break; case "M_PROFILE_NOT_FOUND": if (!ignoreProfile) { @@ -241,7 +255,11 @@ export default class MultiInviter { errorText = _t("The user must be unbanned before they can be invited."); break; case "M_UNSUPPORTED_ROOM_VERSION": - errorText = _t("The user's homeserver does not support the version of the room."); + if (isSpace) { + errorText = _t("The user's homeserver does not support the version of the space."); + } else { + errorText = _t("The user's homeserver does not support the version of the room."); + } break; }