Skip to content

Commit

Permalink
improve translations
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-rajpal committed Jun 18, 2024
1 parent a53ae74 commit ad83cb4
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 24 deletions.
47 changes: 34 additions & 13 deletions apps/meteor/client/lib/getRoomTypeTranslation.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,39 @@
import type { IRoom } from '@rocket.chat/core-typings';
import {
isPublicRoom,
type IRoom,
isDirectMessageRoom,
isPrivateTeamRoom,
isPublicTeamRoom,
isPrivateDiscussion,
isPrivateRoom,
} from '@rocket.chat/core-typings';

import { t } from '../../app/utils/lib/i18n';

export const getRoomTypeTranslation = (type: IRoom['t']) => {
switch (type) {
case 'c':
return t('Channel');
case 'p':
return t('Private_Group');
case 'd':
return t('Direct_Message');
case 'l':
return t('Livechat');
default:
return t('Room');
export const getRoomTypeTranslation = (room: IRoom) => {
if (isPublicRoom(room)) {
return t('Channel');
}

if (isPrivateDiscussion(room)) {
return t('Private_Discussion');
}

if (isPrivateRoom(room)) {
return t('Private_Group');
}

if (isDirectMessageRoom(room)) {
return t('Direct_Message');
}

if (isPrivateTeamRoom(room)) {
return t('Teams_Private_Team');
}

if (isPublicTeamRoom(room)) {
return t('Teams_Public_Team');
}

return t('Room');
};
11 changes: 2 additions & 9 deletions apps/meteor/client/views/audit/components/tabs/RoomsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type { UseFormReturn } from 'react-hook-form';
import { useController } from 'react-hook-form';

import RoomAutoComplete from '../../../../components/RoomAutoComplete';
import { getRoomTypeTranslation } from '../../../../lib/getRoomTypeTranslation';
import type { AuditFields } from '../../hooks/useAuditForm';

type RoomsTabProps = {
Expand All @@ -30,14 +29,8 @@ const RoomsTab = ({ form: { control }, setSelectedRoom }: RoomsTabProps) => {
error={!!ridFieldState.error}
placeholder={t('Channel_Name_Placeholder')}
onChange={ridField.onChange}
renderRoomIcon={({ encrypted, type }) =>
encrypted ? (
<Icon
name='key'
color='danger'
title={t('Encrypted_content_will_not_appear_search', { roomType: getRoomTypeTranslation(type).toLowerCase() })}
/>
) : null
renderRoomIcon={({ encrypted }) =>
encrypted ? <Icon name='key' color='danger' title={t('Encrypted_content_will_not_appear_search')} /> : null
}
/>
</FieldRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const MessageSearchForm = ({ provider, onSearch }: MessageSearchFormProps) => {
</Box>
{room.encrypted && (
<Callout type='warning' mbs={12} icon='circle-exclamation'>
<Box fontScale='p2b'>{t('Encrypted_RoomType', { roomType: getRoomTypeTranslation(room.t).toLowerCase() })}</Box>
<Box fontScale='p2b'>{t('Encrypted_RoomType', { roomType: getRoomTypeTranslation(room).toLowerCase() })}</Box>
{t('Encrypted_content_cannot_be_searched')}
</Callout>
)}
Expand Down
1 change: 1 addition & 0 deletions packages/core-typings/src/IRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const isPrivateDiscussion = (room: Partial<IRoom>): room is IRoom => isDi
export const isPublicDiscussion = (room: Partial<IRoom>): room is IRoom => isDiscussion(room) && room.t === 'c';

export const isPublicRoom = (room: Partial<IRoom>): room is IRoom => room.t === 'c';
export const isPrivateRoom = (room: Partial<IRoom>): room is IRoom => room.t === 'p';

export interface IDirectMessageRoom extends Omit<IRoom, 'default' | 'featured' | 'u' | 'name'> {
t: 'd';
Expand Down
3 changes: 2 additions & 1 deletion packages/i18n/src/locales/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -4241,6 +4241,7 @@
"Private_Channel": "Private Channel",
"Private_Channels": "Private channels",
"Private_Chats": "Private Chats",
"Private_Discussion": "Private discussion",
"Private_Group": "Private Group",
"Private_Groups": "Private groups",
"Private_Groups_list": "List of Private Groups",
Expand Down Expand Up @@ -6425,7 +6426,7 @@
"unread_messages_other": "{{count}} unread messages",
"Encrypted_messages": "End-to-end encrypted {{roomType}}. Search will not work with encrypted {{roomType}} and notifications may not show the messages content.",
"Encrypted_messages_false": "Messages are not encrypted",
"Encrypted_content_will_not_appear_search": "{{roomType}} encrypted, encrypted content will not appear in search",
"Encrypted_content_will_not_appear_search": "Room encrypted, encrypted content will not appear in search",
"Encrypted_content_cannot_be_searched_and_audited": "Encrypted content cannot be searched and audited",
"Encrypted_content_cannot_be_searched_and_audited_subtitle": "There are one or more encrypted rooms selected for audit.",
"Not_available_for_broadcast": "Not available for broadcast {{roomType}}",
Expand Down

0 comments on commit ad83cb4

Please sign in to comment.