Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Make more strings either space/room specific or more ambiguous if unk…
Browse files Browse the repository at this point in the history
…nown
  • Loading branch information
t3chguy committed Mar 24, 2022
1 parent c159d55 commit dfdbb6b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/RoomInvite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/components/views/right_panel/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
18 changes: 11 additions & 7 deletions src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <RoomName/>": "We sent the others, but the below people couldn't be invited to <RoomName/>",
"Some invites couldn't be sent": "Some invites couldn't be sent",
"%(space1Name)s and %(space2Name)s": "%(space1Name)s and %(space2Name)s",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
16 changes: 8 additions & 8 deletions src/stores/RoomViewStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,13 @@ class RoomViewStore extends Store<ActionPayload> {
}

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 = <div>
description = <div>
{ _t("Sorry, your homeserver is too old to participate in this room.") }<br />
{ _t("Please contact your homeserver administrator.") }
</div>;
Expand All @@ -395,18 +395,18 @@ class RoomViewStore extends Store<ActionPayload> {
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.");
}
}
}

// 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,
});
}

Expand Down
32 changes: 25 additions & 7 deletions src/utils/MultiInviter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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;
}

Expand Down

0 comments on commit dfdbb6b

Please sign in to comment.