Skip to content

Commit

Permalink
i18n: system message copy updates (#29372)
Browse files Browse the repository at this point in the history
Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com>
  • Loading branch information
heitortanoue and gabriellsh authored Jun 7, 2023
1 parent 29556cb commit ea0bbba
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-masks-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fixed system messages for room role changes
6 changes: 2 additions & 4 deletions apps/meteor/app/lib/lib/MessageTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,24 +189,22 @@ Meteor.startup(function () {
MessageTypes.registerType({
id: 'subscription-role-added',
system: true,
message: '__username__was_set__role__by__user_by_',
message: 'set__username__as__role_',
data(message) {
return {
username: message.msg,
role: message.role || '',
user_by: message.u.username,
};
},
});
MessageTypes.registerType({
id: 'subscription-role-removed',
system: true,
message: '__username__is_no_longer__role__defined_by__user_by_',
message: 'removed__username__as__role_',
data(message) {
return {
username: message.msg,
role: message.role || '',
user_by: message.u.username,
};
},
});
Expand Down
6 changes: 2 additions & 4 deletions apps/meteor/client/startup/messageTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ Meteor.startup(() => {
MessageTypes.registerType({
id: 'room_changed_announcement',
system: true,
message: 'room_changed_announcement',
message: 'changed_room_announcement_to__room_announcement_',
data(message: IMessage) {
return {
user_by: message.u?.username,
room_announcement: escapeHTML(message.msg || `(${t('None').toLowerCase()})`),
};
},
Expand All @@ -49,10 +48,9 @@ Meteor.startup(() => {
MessageTypes.registerType({
id: 'room_changed_description',
system: true,
message: 'room_changed_description',
message: 'changed_room_description_to__room_description_',
data(message: IMessage) {
return {
user_by: message.u?.username,
room_description: escapeHTML(message.msg || `(${t('None').toLowerCase()})`),
};
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type { IRoom, IUser } from '@rocket.chat/core-typings';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { escapeHTML } from '@rocket.chat/string-helpers';
import { useTranslation, usePermission, useUserRoom, useUserSubscription } from '@rocket.chat/ui-contexts';
import { useMemo } from 'react';

import { useEndpointAction } from '../../../../../hooks/useEndpointAction';
import { roomCoordinator } from '../../../../../lib/rooms/roomCoordinator';
import type { Action } from '../../../../hooks/useActionSpread';
import { getRoomDirectives } from '../../../lib/getRoomDirectives';
import { useUserHasRoomRole } from '../../useUserHasRoomRole';
Expand All @@ -25,14 +23,11 @@ export const useChangeLeaderAction = (user: Pick<IUser, '_id' | 'username'>, rid
const endpointPrefix = room.t === 'p' ? '/v1/groups' : '/v1/channels';
const { roomCanSetLeader } = getRoomDirectives({ room, showingUserId: uid, userSubscription });
const isLeader = useUserHasRoomRole(uid, rid, 'leader');
const roomName = room?.t && escapeHTML(roomCoordinator.getRoomName(room.t, room));

const changeLeaderEndpoint = isLeader ? 'removeLeader' : 'addLeader';
const changeLeaderMessage = isLeader
? 'User__username__removed_from__room_name__leaders'
: 'User__username__is_now_a_leader_of__room_name_';
const changeLeaderMessage = isLeader ? 'removed__username__as__role_' : 'set__username__as__role_';
const changeLeader = useEndpointAction('POST', `${endpointPrefix}.${changeLeaderEndpoint}`, {
successMessage: t(changeLeaderMessage, { username: user.username, room_name: roomName }),
successMessage: t(changeLeaderMessage, { username: user.username, role: 'leader' }),
});
const changeLeaderAction = useMutableCallback(() => changeLeader({ roomId: rid, userId: uid }));
const changeLeaderOption = useMemo(
Expand Down
4 changes: 4 additions & 0 deletions apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"__usersCount__people_will_be_invited": "{{usersCount}} people will be invited",
"__username__is_no_longer__role__defined_by__user_by_": "{{username}} is no longer {{role}} by {{user_by}}",
"__username__was_set__role__by__user_by_": "{{username}} was set {{role}} by {{user_by}}",
"removed__username__as__role_": "removed {{username}} as {{role}}",
"set__username__as__role_": "set {{username}} as {{role}}",
"This_room_encryption_has_been_enabled_by__username_": "This room's encryption has been enabled by {{username}}",
"This_room_encryption_has_been_disabled_by__username_": "This room's encryption has been disabled by {{username}}",
"Enabled_E2E_Encryption_for_this_room": "enabled E2E Encryption for this room",
Expand Down Expand Up @@ -894,6 +896,8 @@
"CDN_PREFIX": "CDN Prefix",
"CDN_PREFIX_ALL": "Use CDN Prefix for all assets",
"Certificates_and_Keys": "Certificates and Keys",
"changed_room_announcement_to__room_announcement_": "changed room announcement to: {{room_announcement}}",
"changed_room_description_to__room_description_": "changed room description to: {{room_description}}",
"change-livechat-room-visitor": "Change Livechat Room Visitors",
"change-livechat-room-visitor_description": "Permission to add additional information to the livechat room visitor",
"Change_Room_Type": "Changing the Room Type",
Expand Down

0 comments on commit ea0bbba

Please sign in to comment.