diff --git a/src/components/right/management/ManageGroupRecentActions.tsx b/src/components/right/management/ManageGroupRecentActions.tsx
index c2fc7bb4a..b340da34d 100644
--- a/src/components/right/management/ManageGroupRecentActions.tsx
+++ b/src/components/right/management/ManageGroupRecentActions.tsx
@@ -111,7 +111,7 @@ const ManageGroupRecentActions: FC = ({ chat }) => {
-
Admins
+
{lang('Channel.Management.Title')}
{
+ const lang = useLang();
+
const {
toggleChatPinned,
updateChatMutedState,
@@ -31,23 +36,39 @@ export default ({
const isChatWithSelf = privateChatUser && privateChatUser.isSelf;
const actionUnreadMark = chat.unreadCount || chat.hasUnreadMark
- ? { title: 'Mark as Read', icon: 'readchats', handler: () => toggleChatUnread({ id: chat.id }) }
- : { title: 'Mark as Unread', icon: 'unread', handler: () => toggleChatUnread({ id: chat.id }) };
+ ? { title: lang('MarkAsRead'), icon: 'readchats', handler: () => toggleChatUnread({ id: chat.id }) }
+ : { title: lang('MarkAsUnread'), icon: 'unread', handler: () => toggleChatUnread({ id: chat.id }) };
const actionPin = isPinned
- ? { title: 'Unpin', icon: 'unpin', handler: () => toggleChatPinned({ id: chat.id, folderId }) }
- : { title: 'Pin', icon: 'pin', handler: () => toggleChatPinned({ id: chat.id, folderId }) };
+ ? {
+ title: lang('UnpinFromTop'),
+ icon: 'unpin',
+ handler: () => toggleChatPinned({ id: chat.id, folderId }),
+ }
+ : { title: lang('PinToTop'), icon: 'pin', handler: () => toggleChatPinned({ id: chat.id, folderId }) };
const actionMute = chat.isMuted
- ? { title: 'Unmute', icon: 'unmute', handler: () => updateChatMutedState({ chatId: chat.id, isMuted: false }) }
- : { title: 'Mute', icon: 'mute', handler: () => updateChatMutedState({ chatId: chat.id, isMuted: true }) };
+ ? {
+ title: lang('ChatList.Unmute'),
+ icon: 'unmute',
+ handler: () => updateChatMutedState({ chatId: chat.id, isMuted: false }),
+ }
+ : {
+ title: lang('ChatList.Mute'),
+ icon: 'mute',
+ handler: () => updateChatMutedState({ chatId: chat.id, isMuted: true }),
+ };
const actionArchive = isChatArchived(chat)
- ? { title: 'Unarchive', icon: 'unarchive', handler: () => toggleChatArchived({ id: chat.id }) }
- : { title: 'Archive', icon: 'archive', handler: () => toggleChatArchived({ id: chat.id }) };
+ ? { title: lang('Unarchive'), icon: 'unarchive', handler: () => toggleChatArchived({ id: chat.id }) }
+ : { title: lang('Archive'), icon: 'archive', handler: () => toggleChatArchived({ id: chat.id }) };
const actionDelete = {
- title: isChatPrivate(chat.id) ? 'Delete' : (getCanDeleteChat(chat) ? 'Delete and Leave' : 'Leave'),
+ title: isChatPrivate(chat.id)
+ ? lang('Delete')
+ : lang(getCanDeleteChat(chat)
+ ? 'DeleteChat'
+ : (isChatChannel(chat) ? 'LeaveChannel' : 'Group.LeaveGroup')),
icon: 'delete',
destructive: true,
handler: handleDelete,
@@ -63,7 +84,7 @@ export default ({
actionDelete,
];
}, [
- chat, privateChatUser, handleDelete, folderId, isPinned,
- toggleChatPinned, updateChatMutedState, toggleChatArchived, toggleChatUnread,
+ chat, privateChatUser, lang, isPinned, handleDelete, toggleChatUnread, toggleChatPinned, folderId,
+ updateChatMutedState, toggleChatArchived,
]);
};
diff --git a/src/modules/helpers/chats.ts b/src/modules/helpers/chats.ts
index 5cf31a985..7bf0ec258 100644
--- a/src/modules/helpers/chats.ts
+++ b/src/modules/helpers/chats.ts
@@ -428,7 +428,7 @@ export function getMessageSenderName(chatId: number, sender?: ApiUser) {
}
if (sender.isSelf) {
- return 'You';
+ return getTranslation('FromYou');
}
return getUserFirstOrLastName(sender);
diff --git a/src/modules/helpers/messages.ts b/src/modules/helpers/messages.ts
index fdaa6122d..9207ebaa8 100644
--- a/src/modules/helpers/messages.ts
+++ b/src/modules/helpers/messages.ts
@@ -1,6 +1,7 @@
import {
ApiChat, ApiMessage, ApiMessageEntityTypes, ApiUser,
} from '../../api/types';
+import { LangFn } from '../../hooks/useLang';
import { LOCAL_MESSAGE_ID_BASE, SERVICE_NOTIFICATIONS_USER_ID, RE_LINK_TEMPLATE } from '../../config';
import parseEmojiOnlyString from '../../components/common/helpers/parseEmojiOnlyString';
@@ -26,62 +27,34 @@ export function getMessageOriginalId(message: ApiMessage) {
return message.previousLocalId || message.id;
}
-export function getMessageSummaryText(message: ApiMessage, noEmoji = false) {
+export function getMessageSummaryText(lang: LangFn, message: ApiMessage, noEmoji = false) {
const {
text, photo, video, audio, voice, document, sticker, contact, poll, invoice,
} = message.content;
if (message.groupedId) {
- if (text) {
- return `${noEmoji ? '' : '🖼 '}${text.text}`;
- }
-
- return 'Album';
+ return `${noEmoji ? '' : '🖼 '}${text ? text.text : lang('lng_in_dlg_album')}`;
}
if (photo) {
- if (text) {
- return `${noEmoji ? '' : '🖼 '}${text.text}`;
- }
-
- return 'Photo';
+ return `${noEmoji ? '' : '🖼 '}${text ? text.text : lang('AttachPhoto')}`;
}
if (video) {
- if (video.isGif) {
- if (text) {
- return `${noEmoji ? '' : 'GIF '}${text.text}`;
- }
-
- return 'GIF';
- } else {
- if (text) {
- return `${noEmoji ? '' : '📹 '}${text.text}`;
- }
-
- return 'Video';
- }
+ return `${noEmoji ? '' : '📹 '}${text ? text.text : lang(video.isGif ? 'AttachGif' : 'AttachVideo')}`;
}
if (sticker) {
- return `${sticker.emoji} Sticker`;
+ return `${sticker.emoji} ${lang('AttachSticker')} `;
}
if (audio) {
const caption = [audio.title, audio.performer].filter(Boolean).join(' — ') || (text && text.text);
- if (caption) {
- return `🎧 ${caption}`;
- }
-
- return 'Audio';
+ return `${noEmoji ? '' : '🎧 '}${caption || lang('AttachMusic')}`;
}
if (voice) {
- if (text) {
- return `${noEmoji ? '' : '🎤 '}${text.text}`;
- }
-
- return 'Voice Message';
+ return `${noEmoji ? '' : '🎤 '}${text ? text.text : lang('AttachAudio')}`;
}
if (document) {
@@ -89,11 +62,11 @@ export function getMessageSummaryText(message: ApiMessage, noEmoji = false) {
}
if (contact) {
- return 'Contact';
+ return lang('AttachContact');
}
if (poll) {
- return `📊 ${poll.summary.question}`;
+ return `${noEmoji ? '' : '📊 '}${poll.summary.question}`;
}
if (invoice) {
@@ -107,60 +80,6 @@ export function getMessageSummaryText(message: ApiMessage, noEmoji = false) {
return CONTENT_NOT_SUPPORTED;
}
-export function getNotificationText(message: ApiMessage) {
- const {
- text, photo, video, audio, voice, document, sticker, contact, poll, invoice,
- } = message.content;
-
- if (message.groupedId) {
- return `🖼 ${text ? text.text : 'Album'}`;
- }
-
- if (photo) {
- return `🖼 ${text ? text.text : 'Photo'}`;
- }
-
- if (video) {
- return `📹 ${text ? text.text : video.isGif ? 'GIF' : 'Video'}`;
- }
-
- if (sticker) {
- return `${sticker.emoji} Sticker `;
- }
-
- if (audio) {
- const caption = [audio.title, audio.performer].filter(Boolean).join(' — ') || (text && text.text);
- return `🎧 ${caption || 'Audio'}`;
- }
-
- if (voice) {
- return `🎤 ${text ? text.text : 'Voice Message'}`;
- }
-
- if (document) {
- return `📎 ${text ? text.text : document.fileName}`;
- }
-
- if (contact) {
- return 'Contact';
- }
-
- if (poll) {
- return `📊 ${poll.summary.question}`;
- }
-
- if (invoice) {
- return 'Invoice';
- }
-
- if (text) {
- return text.text;
- }
-
- return CONTENT_NOT_SUPPORTED;
-}
-
-
export function getMessageText(message: ApiMessage) {
const {
text, sticker, photo, video, audio, voice, document, poll, webPage, contact, invoice,
diff --git a/src/modules/helpers/users.ts b/src/modules/helpers/users.ts
index e12e5e019..cc65d8c74 100644
--- a/src/modules/helpers/users.ts
+++ b/src/modules/helpers/users.ts
@@ -70,7 +70,7 @@ export function getUserStatus(user: ApiUser, lang: LangFn) {
}
if (user.type && user.type === 'userTypeBot') {
- return 'bot';
+ return lang('Bot');
}
if (!user.status) {
diff --git a/src/util/notifications.ts b/src/util/notifications.ts
index 874586fb1..cfc3778fe 100644
--- a/src/util/notifications.ts
+++ b/src/util/notifications.ts
@@ -7,11 +7,12 @@ import {
getChatTitle,
getMessageAction,
getMessageSenderName,
- getNotificationText,
+ getMessageSummaryText,
getPrivateChatUserId,
isActionMessage,
isChatChannel,
} from '../modules/helpers';
+import { getTranslation } from './langProvider';
import { replaceSettings } from '../modules/reducers';
import { selectChatMessage, selectUser } from '../modules/selectors';
import { IS_SERVICE_WORKER_SUPPORTED } from './environment';
@@ -225,6 +226,7 @@ function getNotificationContent(chat: ApiChat, message: ApiMessage) {
? chat
: messageSender;
body = renderActionMessageText(
+ getTranslation,
message,
actionOrigin,
actionTargetUser,
@@ -234,7 +236,7 @@ function getNotificationContent(chat: ApiChat, message: ApiMessage) {
) as string;
} else {
const senderName = getMessageSenderName(chat.id, messageSender);
- const summary = getNotificationText(message);
+ const summary = getMessageSummaryText(getTranslation, message);
body = senderName ? `${senderName}: ${summary}` : summary;
}
diff --git a/tests/assertions.ts b/tests/assertions.ts
index 413198ae1..f9f31671e 100644
--- a/tests/assertions.ts
+++ b/tests/assertions.ts
@@ -137,7 +137,7 @@ export function expectCommentButton(
expect(button.querySelector('.label')).toHaveTextContent(`${commentsCount} Comments`);
expect(button.querySelectorAll('.Avatar')).toHaveLength(Math.min(authorsCount, 3));
} else {
- expect(button.querySelector('.label')).toHaveTextContent('Leave a Comment');
+ expect(button.querySelector('.label')).toHaveTextContent('Leave a comment');
expect(button.querySelectorAll('.Avatar')).toHaveLength(0);
}