diff --git a/src/api/gramjs/methods/settings.ts b/src/api/gramjs/methods/settings.ts index 811b70b29..699564c4d 100644 --- a/src/api/gramjs/methods/settings.ts +++ b/src/api/gramjs/methods/settings.ts @@ -18,6 +18,7 @@ import { buildCollectionByKey } from '../../../util/iteratees'; import localDb from '../localDb'; const MAX_INT_32 = 2 ** 31 - 1; +const BETA_LANG_CODES = ['ar', 'fa']; export function updateProfile({ firstName, @@ -250,7 +251,10 @@ export async function fetchLanguages(): Promise { export async function fetchLangPack({ sourceLangPacks, langCode }: { sourceLangPacks: string[]; langCode: string }) { const results = await Promise.all(sourceLangPacks.map((langPack) => { - return invokeRequest(new GramJs.langpack.GetLangPack({ langPack, langCode })); + return invokeRequest(new GramJs.langpack.GetLangPack({ + langPack, + langCode: BETA_LANG_CODES.includes(langCode) ? `${langCode}-raw` : langCode, + })); })); const collections = results diff --git a/src/components/common/DeleteChatModal.tsx b/src/components/common/DeleteChatModal.tsx index 6e56abc73..febca9c79 100644 --- a/src/components/common/DeleteChatModal.tsx +++ b/src/components/common/DeleteChatModal.tsx @@ -16,6 +16,7 @@ import { } from '../../modules/helpers'; import { pick } from '../../util/iteratees'; import useLang from '../../hooks/useLang'; +import renderText from './helpers/renderText'; import Avatar from './Avatar'; import Modal from '../ui/Modal'; @@ -96,55 +97,52 @@ const DeleteChatModal: FC = ({ chat={chat} isSavedMessages={isChatWithSelf} /> -

{renderTitle()}

+

{lang(renderTitle())}

); } function renderTitle() { if (isChannel && !chat.isCreator) { - return 'Leave Channel?'; + return 'LeaveChannel'; } if (isChannel && chat.isCreator) { - return 'Delete and Leave Channel?'; + return 'ChannelDelete'; } if (isBasicGroup || isSuperGroup) { - return 'Leave Group?'; + return 'Group.LeaveGroup'; } - return 'Delete Chat?'; + return 'DeleteChatUser'; } function renderMessage() { - if (isChannel && !chat.isCreator) { - return

Are you sure you want to leave channel {chatTitle}?

; - } if (isChannel && chat.isCreator) { - return

Are you sure you want to delete and leave channel {chatTitle}?

; + return

{renderText(lang('ChatList.DeleteAndLeaveGroupConfirmation', chatTitle), ['simple_markdown'])}

; } - if (isBasicGroup || isSuperGroup) { - return

Are you sure you want to leave group {chatTitle}?

; + if ((isChannel && !chat.isCreator) || isBasicGroup || isSuperGroup) { + return

{renderText(lang('ChannelLeaveAlertWithName', chatTitle), ['simple_markdown'])}

; } - return

Are you sure you want to delete chat with {contactName}?

; + return

{renderText(lang('ChatList.DeleteChatConfirmation', contactName), ['simple_markdown'])}

; } function renderActionText() { if (isChannel && !chat.isCreator) { - return 'Leave Channel'; + return 'LeaveChannel'; } if (isChannel && chat.isCreator) { - return 'Delete and Leave Channel'; + return 'Chat.Input.Delete'; } if (isBasicGroup || isSuperGroup) { - return 'Leave Group'; + return 'Group.LeaveGroup'; } - return `Delete${canDeleteForAll ? ' just for me' : ''}`; + return canDeleteForAll ? 'ChatList.DeleteForCurrentUser' : 'Delete'; } return ( @@ -157,11 +155,11 @@ const DeleteChatModal: FC = ({ {renderMessage()} {canDeleteForAll && ( )} diff --git a/src/components/common/DeleteMessageModal.tsx b/src/components/common/DeleteMessageModal.tsx index 9ad8fe288..c454095c7 100644 --- a/src/components/common/DeleteMessageModal.tsx +++ b/src/components/common/DeleteMessageModal.tsx @@ -91,19 +91,19 @@ const DeleteMessageModal: FC = ({ >

{lang('AreYouSureDeleteSingleMessage')}

{willDeleteForCurrentUserOnly && ( -

This will delete it just for you, not for other participants in the chat.

+

{lang('lng_delete_for_me_chat_hint')}

)} {willDeleteForAll && ( -

This will delete it for everyone in this chat.

+

{lang('lng_delete_for_everyone_hint')}

)} {canDeleteForAll && ( )} diff --git a/src/components/common/EmbeddedMessage.tsx b/src/components/common/EmbeddedMessage.tsx index fc883ca99..07d1bb822 100644 --- a/src/components/common/EmbeddedMessage.tsx +++ b/src/components/common/EmbeddedMessage.tsx @@ -49,7 +49,7 @@ const EmbeddedMessage: FC = ({ const pictogramId = message && `sticker-reply-thumb${message.id}`; const mediaThumbnail = useWebpThumbnail(message); - useLang(); + const lang = useLang(); const senderTitle = sender && getSenderTitle(sender); @@ -68,7 +68,7 @@ const EmbeddedMessage: FC = ({ ) : isActionMessage(message) ? ( ) : ( - renderText(getMessageSummaryText(message, Boolean(mediaThumbnail))) + renderText(getMessageSummaryText(lang, message, Boolean(mediaThumbnail))) )}

diff --git a/src/components/common/NothingFound.scss b/src/components/common/NothingFound.scss index 30e7fcf19..e15fa6820 100644 --- a/src/components/common/NothingFound.scss +++ b/src/components/common/NothingFound.scss @@ -4,7 +4,19 @@ justify-content: center; color: var(--color-text-meta); + &.with-description { + flex-direction: column; + } + .AnimatedSticker { margin: 0 auto; } + + .description { + color: var(--color-text-secondary); + font-size: .875rem; + text-align: center; + margin: 1rem 0 0; + unicode-bidi: plaintext; + } } diff --git a/src/components/common/NothingFound.tsx b/src/components/common/NothingFound.tsx index 9555537d2..ad8fa97f2 100644 --- a/src/components/common/NothingFound.tsx +++ b/src/components/common/NothingFound.tsx @@ -2,21 +2,26 @@ import React, { FC, memo } from '../../lib/teact/teact'; import buildClassName from '../../util/buildClassName'; import useShowTransition from '../../hooks/useShowTransition'; +import renderText from './helpers/renderText'; +import useLang from '../../hooks/useLang'; import './NothingFound.scss'; interface OwnProps { text?: string; + description?: string; } const DEFAULT_TEXT = 'Nothing found.'; -const NothingFound: FC = ({ text = DEFAULT_TEXT }) => { +const NothingFound: FC = ({ text = DEFAULT_TEXT, description }) => { + const lang = useLang(); const { transitionClassNames } = useShowTransition(true); return ( -
+
{text} + {description &&

{renderText(lang(description), ['br'])}

}
); }; diff --git a/src/components/common/StickerSetModal.tsx b/src/components/common/StickerSetModal.tsx index a4bad5fa7..1b6808708 100644 --- a/src/components/common/StickerSetModal.tsx +++ b/src/components/common/StickerSetModal.tsx @@ -10,6 +10,7 @@ import { STICKER_SIZE_MODAL } from '../../config'; import { pick } from '../../util/iteratees'; import { selectStickerSet } from '../../modules/selectors'; import { useIntersectionObserver } from '../../hooks/useIntersectionObserver'; +import useLang from '../../hooks/useLang'; import Modal from '../ui/Modal'; import Button from '../ui/Button'; @@ -43,6 +44,7 @@ const StickerSetModal: FC = ({ }) => { // eslint-disable-next-line no-null/no-null const containerRef = useRef(null); + const lang = useLang(); const { observe: observeIntersection, @@ -98,7 +100,11 @@ const StickerSetModal: FC = ({ color={stickerSet.installedDate ? 'danger' : 'primary'} onClick={handleButtonClick} > - {`${stickerSet.installedDate ? 'Remove' : 'Add'} ${stickerSet.count} stickers`} + {lang( + stickerSet.installedDate ? 'StickerPack.RemoveStickerCount' : 'StickerPack.AddStickerCount', + stickerSet.count, + 'i', + )}
diff --git a/src/components/common/WebLink.tsx b/src/components/common/WebLink.tsx index 9bf5153b0..33d130c5a 100644 --- a/src/components/common/WebLink.tsx +++ b/src/components/common/WebLink.tsx @@ -7,6 +7,7 @@ import buildClassName from '../../util/buildClassName'; import trimText from '../../util/trimText'; import renderText from './helpers/renderText'; import { formatPastTimeShort } from '../../util/dateFormat'; +import useLang from '../../hooks/useLang'; import Media from './Media'; import Link from '../ui/Link'; @@ -23,13 +24,15 @@ type OwnProps = { }; const WebLink: FC = ({ message, senderTitle, onMessageClick }) => { + const lang = useLang(); + let linkData: ApiWebPage | undefined = getMessageWebPage(message); if (!linkData) { const link = getFirstLinkInMessage(message); if (link) { const { url, domain } = link; - const messageText = getMessageSummaryText(message); + const messageText = getMessageSummaryText(lang, message); linkData = { siteName: domain.replace(/^www./, ''), diff --git a/src/components/common/helpers/renderActionMessageText.tsx b/src/components/common/helpers/renderActionMessageText.tsx index 552504ac4..4e74d9890 100644 --- a/src/components/common/helpers/renderActionMessageText.tsx +++ b/src/components/common/helpers/renderActionMessageText.tsx @@ -1,6 +1,7 @@ import React from '../../../lib/teact/teact'; import { ApiChat, ApiMessage, ApiUser } from '../../../api/types'; +import { LangFn } from '../../../hooks/useLang'; import { getChatTitle, getMessageContent, @@ -25,6 +26,7 @@ interface ActionMessageTextOptions { const NBSP = '\u00A0'; export function renderActionMessageText( + lang: LangFn, message: ApiMessage, actionOrigin?: ApiUser | ApiChat, targetUser?: ApiUser, @@ -66,7 +68,7 @@ export function renderActionMessageText( unprocessed, '%message%', targetMessage - ? renderMessageContent(targetMessage, textOptions) + ? renderMessageContent(lang, targetMessage, textOptions) : 'a message', ); unprocessed = processed.pop() as string; @@ -104,8 +106,8 @@ function renderProductContent(message: ApiMessage) { : 'a product'; } -function renderMessageContent(message: ApiMessage, options: ActionMessageTextOptions = {}) { - const text = getMessageSummaryText(message); +function renderMessageContent(lang: LangFn, message: ApiMessage, options: ActionMessageTextOptions = {}) { + const text = getMessageSummaryText(lang, message); const { photo, video, document, sticker, } = getMessageContent(message); diff --git a/src/components/left/NewChatButton.tsx b/src/components/left/NewChatButton.tsx index 356a99837..ddb8b600d 100644 --- a/src/components/left/NewChatButton.tsx +++ b/src/components/left/NewChatButton.tsx @@ -80,7 +80,7 @@ const NewChatButton: FC = ({ color="primary" className={isMenuOpen ? 'active' : ''} onClick={toggleIsMenuOpen} - ariaLabel={isMenuOpen ? 'Close' : 'Create new chat'} + ariaLabel={lang(isMenuOpen ? 'Close' : 'NewMessageTitle')} tabIndex={-1} > @@ -95,7 +95,7 @@ const NewChatButton: FC = ({ > {lang('NewChannel')} {lang('NewGroup')} - New Private Chat + {lang('NewMessageTitle')} ); diff --git a/src/components/left/main/Chat.tsx b/src/components/left/main/Chat.tsx index 0f960556f..b4b978c7c 100644 --- a/src/components/left/main/Chat.tsx +++ b/src/components/left/main/Chat.tsx @@ -3,7 +3,7 @@ import React, { } from '../../../lib/teact/teact'; import { withGlobal } from '../../../lib/teact/teactn'; -import useLang from '../../../hooks/useLang'; +import useLang, { LangFn } from '../../../hooks/useLang'; import { GlobalActions, MessageListType } from '../../../global/types'; import { @@ -205,6 +205,7 @@ const Chat: FC = ({ return (

{renderText(renderActionMessageText( + lang, lastMessage, actionOrigin, actionTargetUser, @@ -223,7 +224,7 @@ const Chat: FC = ({ {senderName && ( {renderText(senderName)} )} - {renderMessageSummary(lastMessage!, mediaBlobUrl || mediaThumbnail)} + {renderMessageSummary(lang, lastMessage!, mediaBlobUrl || mediaThumbnail)}

); } @@ -273,16 +274,16 @@ const Chat: FC = ({ ); }; -function renderMessageSummary(message: ApiMessage, blobUrl?: string) { +function renderMessageSummary(lang: LangFn, message: ApiMessage, blobUrl?: string) { if (!blobUrl) { - return renderText(getMessageSummaryText(message)); + return renderText(getMessageSummaryText(lang, message)); } return ( {getMessageVideo(message) && } - {renderText(getMessageSummaryText(message, true))} + {renderText(getMessageSummaryText(lang, message, true))} ); } diff --git a/src/components/left/main/ChatFolders.tsx b/src/components/left/main/ChatFolders.tsx index 68969a284..df59ccffe 100644 --- a/src/components/left/main/ChatFolders.tsx +++ b/src/components/left/main/ChatFolders.tsx @@ -43,6 +43,8 @@ const ChatFolders: FC = ({ // eslint-disable-next-line no-null/no-null const transitionRef = useRef(null); + const lang = useLang(); + const [activeTab, setActiveTab] = useState(0); useEffect(() => { @@ -84,13 +86,13 @@ const ChatFolders: FC = ({ } return [ - { title: 'All' }, + { title: lang('FilterAllChats') }, ...displayedFolders.map((folder) => ({ title: folder.title, ...(folderCountersById && folderCountersById[folder.id]), })), ]; - }, [displayedFolders, folderCountersById]); + }, [displayedFolders, folderCountersById, lang]); const handleSwitchTab = useCallback((index: number) => { setActiveTab(index); @@ -135,8 +137,6 @@ const ChatFolders: FC = ({ shouldRender: shouldRenderPlaceholder, transitionClassNames, } = useShowTransition(!orderedFolderIds, undefined, true); - const lang = useLang(); - function renderCurrentTab() { const activeFolder = Object.values(chatFoldersById) .find(({ title }) => title === folderTabs![activeTab].title); diff --git a/src/components/left/main/LeftMainHeader.tsx b/src/components/left/main/LeftMainHeader.tsx index 88a8ae489..526d2ef0b 100644 --- a/src/components/left/main/LeftMainHeader.tsx +++ b/src/components/left/main/LeftMainHeader.tsx @@ -76,6 +76,7 @@ const LeftMainHeader: FC = ({ setGlobalSearchDate, setSettingOption, }) => { + const lang = useLang(); const hasMenu = content === LeftColumnContent.ChatList; const clearedDateSearchParam = { date: undefined }; const clearedChatSearchParam = { id: undefined }; @@ -107,12 +108,12 @@ const LeftMainHeader: FC = ({ color="translucent" className={isOpen ? 'active' : ''} onClick={hasMenu ? onTrigger : () => onReset()} - ariaLabel={hasMenu ? 'Open menu' : 'Return to chat list'} + ariaLabel={hasMenu ? lang('AccDescrOpenMenu2') : 'Return to chat list'} >
); - }, [hasMenu, onReset]); + }, [hasMenu, lang, onReset]); const handleSearchFocus = useCallback(() => { if (!searchQuery) { @@ -148,8 +149,6 @@ const LeftMainHeader: FC = ({ setSettingOption({ animationLevel: newLevel }); }, [animationLevel, setSettingOption]); - const lang = useLang(); - const isSearchFocused = ( Boolean(globalSearchChatId) || content === LeftColumnContent.GlobalSearch @@ -198,10 +197,10 @@ const LeftMainHeader: FC = ({ icon="darkmode" onClick={handleDarkModeToggle} > - Dark Mode + {lang('lng_menu_night_mode')} @@ -221,7 +220,7 @@ const LeftMainHeader: FC = ({ icon="help" onClick={openTipsChat} > - Telegram Features + {lang('TelegramFeatures')} = ({ focusMessage, openAudioPlayer, }) => { + const lang = useLang(); const currentType = isVoice ? 'voice' : 'audio'; const handleLoadMore = useCallback(({ direction }: { direction: LoadMoreDirection }) => { if (lastSyncTime && direction === LoadMoreDirection.Backwards) { @@ -115,7 +117,12 @@ const AudioResults: FC = ({ noFastList > {!canRenderContents && } - {canRenderContents && (!foundIds || foundIds.length === 0) && } + {canRenderContents && (!foundIds || foundIds.length === 0) && ( + + )} {canRenderContents && foundIds && foundIds.length > 0 && renderList()}
diff --git a/src/components/left/search/ChatMessage.tsx b/src/components/left/search/ChatMessage.tsx index 2ed98f041..0504c0ee4 100644 --- a/src/components/left/search/ChatMessage.tsx +++ b/src/components/left/search/ChatMessage.tsx @@ -22,7 +22,7 @@ import renderText from '../../common/helpers/renderText'; import { pick } from '../../../util/iteratees'; import useMedia from '../../../hooks/useMedia'; import { formatPastTimeShort } from '../../../util/dateFormat'; -import useLang from '../../../hooks/useLang'; +import useLang, { LangFn } from '../../../hooks/useLang'; import Avatar from '../../common/Avatar'; import VerifiedIcon from '../../common/VerifiedIcon'; @@ -62,7 +62,7 @@ const ChatMessage: FC = ({ focusMessage({ chatId, messageId: message.id }); }, [chatId, focusMessage, message.id]); - useLang(); + const lang = useLang(); if (!chat) { return undefined; @@ -96,7 +96,7 @@ const ChatMessage: FC = ({
- {renderMessageSummary(message, mediaBlobUrl || mediaThumbnail, searchQuery)} + {renderMessageSummary(lang, message, mediaBlobUrl || mediaThumbnail, searchQuery)}
@@ -104,16 +104,16 @@ const ChatMessage: FC = ({ ); }; -function renderMessageSummary(message: ApiMessage, blobUrl?: string, searchQuery?: string) { +function renderMessageSummary(lang: LangFn, message: ApiMessage, blobUrl?: string, searchQuery?: string) { if (!blobUrl) { - return renderText(getMessageSummaryText(message)); + return renderText(getMessageSummaryText(lang, message)); } return ( {getMessageVideo(message) && } - {renderText(getMessageSummaryText(message, true), ['emoji', 'highlight'], { highlight: searchQuery })} + {renderText(getMessageSummaryText(lang, message, true), ['emoji', 'highlight'], { highlight: searchQuery })} ); } diff --git a/src/components/left/search/ChatMessageResults.tsx b/src/components/left/search/ChatMessageResults.tsx index 50a0841b0..f085ccfc4 100644 --- a/src/components/left/search/ChatMessageResults.tsx +++ b/src/components/left/search/ChatMessageResults.tsx @@ -11,6 +11,7 @@ import { pick } from '../../../util/iteratees'; import { getMessageSummaryText } from '../../../modules/helpers'; import { MEMO_EMPTY_ARRAY } from '../../../util/memo'; import { throttle } from '../../../util/schedulers'; +import useLang from '../../../hooks/useLang'; import InfiniteScroll from '../../ui/InfiniteScroll'; import ChatMessage from './ChatMessage'; @@ -49,6 +50,7 @@ const ChatMessageResults: FC = ({ searchMessagesGlobal, onSearchDateSelect, }) => { + const lang = useLang(); const handleLoadMore = useCallback(({ direction }: { direction: LoadMoreDirection }) => { if (lastSyncTime && direction === LoadMoreDirection.Backwards) { runThrottled(() => { @@ -79,7 +81,7 @@ const ChatMessageResults: FC = ({ }, [foundIds, globalMessagesByChatId]); function renderFoundMessage(message: ApiMessage) { - const text = getMessageSummaryText(message); + const text = getMessageSummaryText(lang, message); const chat = chatsById[message.chatId]; if (!text || !chat) { @@ -113,7 +115,12 @@ const ChatMessageResults: FC = ({ /> )} - {nothingFound && } + {nothingFound && ( + + )} {!!foundMessages.length && foundMessages.map(renderFoundMessage)} diff --git a/src/components/left/search/ChatResults.tsx b/src/components/left/search/ChatResults.tsx index 3f39dda15..085520339 100644 --- a/src/components/left/search/ChatResults.tsx +++ b/src/components/left/search/ChatResults.tsx @@ -159,7 +159,7 @@ const ChatResults: FC = ({ const lang = useLang(); function renderFoundMessage(message: ApiMessage) { - const text = getMessageSummaryText(message); + const text = getMessageSummaryText(lang, message); const chat = chatsById[message.chatId]; if (!text || !chat) { @@ -199,7 +199,12 @@ const ChatResults: FC = ({ /> )} - {nothingFound && } + {nothingFound && ( + + )} {!!localResults.length && (
{localResults.map((id) => ( @@ -215,9 +220,11 @@ const ChatResults: FC = ({

{localResults.length > LESS_LIST_ITEMS_AMOUNT && ( - {shouldShowMoreLocal ? 'Show less' : 'Show more'} + + {lang(shouldShowMoreLocal ? 'ChatList.Search.ShowLess' : 'ChatList.Search.ShowMore')} + )} - Contacts and Chats + {lang('DialogList.SearchSectionDialogs')}

{localResults.map((id, index) => { if (!shouldShowMoreLocal && index >= LESS_LIST_ITEMS_AMOUNT) { @@ -237,9 +244,11 @@ const ChatResults: FC = ({

{globalResults.length > LESS_LIST_ITEMS_AMOUNT && ( - {shouldShowMoreGlobal ? 'Show less' : 'Show more'} + + {lang(shouldShowMoreGlobal ? 'ChatList.Search.ShowLess' : 'ChatList.Search.ShowMore')} + )} - Global Search + {lang('DialogList.SearchSectionGlobal')}

{globalResults.map((id, index) => { if (!shouldShowMoreGlobal && index >= LESS_LIST_ITEMS_AMOUNT) { diff --git a/src/components/left/search/FileResults.tsx b/src/components/left/search/FileResults.tsx index ccaf0291e..6c6929d70 100644 --- a/src/components/left/search/FileResults.tsx +++ b/src/components/left/search/FileResults.tsx @@ -16,6 +16,7 @@ import { getSenderName } from './helpers/getSenderName'; import { throttle } from '../../../util/schedulers'; import { getMessageDocument } from '../../../modules/helpers'; import useAsyncRendering from '../../right/hooks/useAsyncRendering'; +import useLang from '../../../hooks/useLang'; import Document from '../../common/Document'; import InfiniteScroll from '../../ui/InfiniteScroll'; @@ -43,6 +44,7 @@ const FileResults: FC = ({ searchMessagesGlobal, focusMessage, }) => { + const lang = useLang(); const handleLoadMore = useCallback(({ direction }: { direction: LoadMoreDirection }) => { if (lastSyncTime && direction === LoadMoreDirection.Backwards) { runThrottled(() => { @@ -109,7 +111,12 @@ const FileResults: FC = ({ noFastList > {!canRenderContents && } - {canRenderContents && (!foundIds || foundIds.length === 0) && } + {canRenderContents && (!foundIds || foundIds.length === 0) && ( + + )} {canRenderContents && foundIds && foundIds.length > 0 && renderList()}
diff --git a/src/components/left/search/LinkResults.tsx b/src/components/left/search/LinkResults.tsx index c830609f7..70d0acabc 100644 --- a/src/components/left/search/LinkResults.tsx +++ b/src/components/left/search/LinkResults.tsx @@ -14,6 +14,7 @@ import { formatMonthAndYear, toYearMonth } from '../../../util/dateFormat'; import { getSenderName } from './helpers/getSenderName'; import { throttle } from '../../../util/schedulers'; import useAsyncRendering from '../../right/hooks/useAsyncRendering'; +import useLang from '../../../hooks/useLang'; import InfiniteScroll from '../../ui/InfiniteScroll'; import WebLink from '../../common/WebLink'; @@ -41,6 +42,7 @@ const LinkResults: FC = ({ searchMessagesGlobal, focusMessage, }) => { + const lang = useLang(); const handleLoadMore = useCallback(({ direction }: { direction: LoadMoreDirection }) => { if (lastSyncTime && direction === LoadMoreDirection.Backwards) { runThrottled(() => { @@ -103,7 +105,12 @@ const LinkResults: FC = ({ noFastList > {!canRenderContents && } - {canRenderContents && (!foundIds || foundIds.length === 0) && } + {canRenderContents && (!foundIds || foundIds.length === 0) && ( + + )} {canRenderContents && foundIds && foundIds.length > 0 && renderList()}
diff --git a/src/components/left/search/MediaResults.tsx b/src/components/left/search/MediaResults.tsx index 2b3e010d1..76422a85d 100644 --- a/src/components/left/search/MediaResults.tsx +++ b/src/components/left/search/MediaResults.tsx @@ -7,17 +7,18 @@ import { GlobalActions } from '../../../global/types'; import { LoadMoreDirection, MediaViewerOrigin } from '../../../types'; import { MEMO_EMPTY_ARRAY } from '../../../util/memo'; +import { SLIDE_TRANSITION_DURATION } from '../../../config'; import { createMapStateToProps, StateProps } from './helpers/createMapStateToProps'; import { pick } from '../../../util/iteratees'; import buildClassName from '../../../util/buildClassName'; import { throttle } from '../../../util/schedulers'; +import useLang from '../../../hooks/useLang'; +import useAsyncRendering from '../../right/hooks/useAsyncRendering'; import InfiniteScroll from '../../ui/InfiniteScroll'; import Media from '../../common/Media'; import ChatMessage from './ChatMessage'; import NothingFound from '../../common/NothingFound'; -import useAsyncRendering from '../../right/hooks/useAsyncRendering'; -import { SLIDE_TRANSITION_DURATION } from '../../../config'; import Loading from '../../ui/Loading'; export type OwnProps = { @@ -39,6 +40,7 @@ const MediaResults: FC = ({ searchMessagesGlobal, openMediaViewer, }) => { + const lang = useLang(); const handleLoadMore = useCallback(({ direction }: { direction: LoadMoreDirection }) => { if (lastSyncTime && direction === LoadMoreDirection.Backwards) { runThrottled(() => { @@ -115,7 +117,12 @@ const MediaResults: FC = ({ noFastList > {!canRenderContents && } - {canRenderContents && (!foundIds || foundIds.length === 0) && } + {canRenderContents && (!foundIds || foundIds.length === 0) && ( + + )} {isMediaGrid && renderGallery()} {isMessageList && renderSearchResult()} diff --git a/src/components/left/settings/SettingsEditProfile.tsx b/src/components/left/settings/SettingsEditProfile.tsx index 8ff3f5d71..95a2f3096 100644 --- a/src/components/left/settings/SettingsEditProfile.tsx +++ b/src/components/left/settings/SettingsEditProfile.tsx @@ -199,7 +199,7 @@ const SettingsEditProfile: FC = ({ />

- {renderText(lang('BioAbout'), ['br', 'simple_markdown'])} + {renderText(lang('lng_settings_about_bio'), ['br', 'simple_markdown'])}

@@ -219,7 +219,7 @@ const SettingsEditProfile: FC = ({

{username && (

- This link opens a chat with you:
+ {lang('lng_username_link')}
https://t.me/{username}

)} diff --git a/src/components/left/settings/SettingsGeneral.tsx b/src/components/left/settings/SettingsGeneral.tsx index 0f77ba424..a10340aa5 100644 --- a/src/components/left/settings/SettingsGeneral.tsx +++ b/src/components/left/settings/SettingsGeneral.tsx @@ -31,11 +31,6 @@ type StateProps = ISettings['byKey'] & { type DispatchProps = Pick; -const KEYBOARD_SEND_OPTIONS = !IS_TOUCH_ENV ? [ - { value: 'enter', label: 'Send by Enter', subLabel: 'New line by Shift + Enter' }, - { value: 'ctrl-enter', label: `Send by ${IS_MAC_OS ? 'Cmd' : 'Ctrl'} + Enter`, subLabel: 'New line by Enter' }, -] : undefined; - const ANIMATION_LEVEL_OPTIONS = [ 'Solid and Steady', 'Nice and Fast', @@ -67,6 +62,17 @@ const SettingsGeneral: FC = ({ const [isModalOpen, openModal, closeModal] = useFlag(); const [sticker, setSticker] = useState(); + const lang = useLang(); + + const KEYBOARD_SEND_OPTIONS = !IS_TOUCH_ENV ? [ + { value: 'enter', label: lang('lng_settings_send_enter'), subLabel: 'New line by Shift + Enter' }, + { + value: 'ctrl-enter', + label: lang(IS_MAC_OS ? 'lng_settings_send_cmdenter' : 'lng_settings_send_ctrlenter'), + subLabel: 'New line by Enter', + }, + ] : undefined; + useEffect(() => { loadStickerSets(); }, [loadStickerSets]); @@ -96,9 +102,6 @@ const SettingsGeneral: FC = ({ openModal(); }, [openModal]); - const lang = useLang(); - - const stickerSets = stickerSetIds && stickerSetIds.map((id: string) => { return stickerSetsById && stickerSetsById[id] && stickerSetsById[id].installedDate ? stickerSetsById[id] : false; }).filter(Boolean); diff --git a/src/components/left/settings/SettingsHeader.tsx b/src/components/left/settings/SettingsHeader.tsx index 811205b2b..af7bfce50 100644 --- a/src/components/left/settings/SettingsHeader.tsx +++ b/src/components/left/settings/SettingsHeader.tsx @@ -83,7 +83,7 @@ const SettingsHeader: FC = ({ function renderHeaderContent() { switch (currentScreen) { case SettingsScreens.EditProfile: - return

{lang('EditProfile')}

; + return

{lang('lng_settings_information')}

; case SettingsScreens.General: return

{lang('General')}

; case SettingsScreens.Notifications: diff --git a/src/components/left/settings/SettingsMain.tsx b/src/components/left/settings/SettingsMain.tsx index d458c0deb..c79e9e8a0 100644 --- a/src/components/left/settings/SettingsMain.tsx +++ b/src/components/left/settings/SettingsMain.tsx @@ -40,7 +40,7 @@ const SettingsMain: FC = ({ icon="edit" onClick={() => onScreenSelect(SettingsScreens.EditProfile)} > - {lang('EditProfile')} + {lang('lng_settings_information')} = ({ focusMessage({ chatId, messageId }); }, [chatId, focusMessage, messageId, closeMediaViewer]); - useLang(); + const lang = useLang(); if (!sender || (!message && !isAvatar)) { return undefined; @@ -62,7 +62,7 @@ const SenderInfo: FC = ({ {senderTitle && renderText(senderTitle)}
- {isAvatar ? 'Profile photo' : formatMediaDateTime(message!.date * 1000)} + {isAvatar ? lang('lng_mediaview_profile_photo') : formatMediaDateTime(message!.date * 1000)}
diff --git a/src/components/middle/ActionMessage.tsx b/src/components/middle/ActionMessage.tsx index ad84aaeb9..b462be1af 100644 --- a/src/components/middle/ActionMessage.tsx +++ b/src/components/middle/ActionMessage.tsx @@ -65,7 +65,7 @@ const ActionMessage: FC = ({ useEnsureMessage(message.chatId, message.replyToMessageId, targetMessage); useFocusMessage(ref, message.chatId, isFocused, focusDirection, noFocusHighlight); - useLang(); + const lang = useLang(); const noAppearanceAnimation = appearanceOrder <= 0; const [isShown, markShown] = useFlag(noAppearanceAnimation); @@ -79,6 +79,7 @@ const ActionMessage: FC = ({ const { transitionClassNames } = useShowTransition(isShown, undefined, noAppearanceAnimation, false); const content = renderActionMessageText( + lang, message, sender, targetUser, diff --git a/src/components/middle/HeaderMenuContainer.tsx b/src/components/middle/HeaderMenuContainer.tsx index 9cb141f96..c7497fb8b 100644 --- a/src/components/middle/HeaderMenuContainer.tsx +++ b/src/components/middle/HeaderMenuContainer.tsx @@ -165,7 +165,9 @@ const HeaderMenuContainer: FC = ({ icon="delete" onClick={handleDelete} > - {lang(isPrivate ? 'Delete' : (canDeleteChat ? 'Delete and Leave' : 'Leave'))} + {lang(isPrivate + ? 'Delete' + : (canDeleteChat ? 'GroupInfo.DeleteAndExit' : (isChannel ? 'LeaveChannel' : 'Group.LeaveGroup')))} )} diff --git a/src/components/middle/HeaderPinnedMessage.tsx b/src/components/middle/HeaderPinnedMessage.tsx index 5f9cdba8e..e9c4f3c5d 100644 --- a/src/components/middle/HeaderPinnedMessage.tsx +++ b/src/components/middle/HeaderPinnedMessage.tsx @@ -31,10 +31,11 @@ type OwnProps = { const HeaderPinnedMessage: FC = ({ message, count, index, customTitle, className, onUnpinMessage, onClick, onAllPinnedClick, }) => { + const lang = useLang(); const mediaThumbnail = useWebpThumbnail(message); const mediaBlobUrl = useMedia(getMessageMediaHash(message, 'pictogram')); - const text = getMessageSummaryText(message, Boolean(mediaThumbnail)); + const text = getMessageSummaryText(lang, message, Boolean(mediaThumbnail)); const [isUnpinDialogOpen, openUnpinDialog, closeUnpinDialog] = useFlag(); const handleUnpinMessage = useCallback(() => { @@ -45,8 +46,6 @@ const HeaderPinnedMessage: FC = ({ } }, [closeUnpinDialog, onUnpinMessage, message.id]); - const lang = useLang(); - return (
{count > 1 && ( diff --git a/src/components/middle/message/CommentButton.tsx b/src/components/middle/message/CommentButton.tsx index e64d195d0..ed07f7a97 100644 --- a/src/components/middle/message/CommentButton.tsx +++ b/src/components/middle/message/CommentButton.tsx @@ -8,9 +8,10 @@ import { GlobalActions } from '../../../global/types'; import { pick } from '../../../util/iteratees'; import { isChatPrivate } from '../../../modules/helpers'; -import { formatInteger, formatIntegerCompact } from '../../../util/textFormat'; +import { formatIntegerCompact } from '../../../util/textFormat'; import buildClassName from '../../../util/buildClassName'; import { selectThreadInfo } from '../../../modules/selectors'; +import useLang from '../../../hooks/useLang'; import Avatar from '../../common/Avatar'; @@ -32,6 +33,7 @@ type DispatchProps = Pick; const CommentButton: FC = ({ disabled, threadInfo, usersById, chatsById, openChat, }) => { + const lang = useLang(); const { threadId, chatId, messagesCount, lastMessageId, lastReadInboxMessageId, recentReplierIds, } = threadInfo; @@ -76,24 +78,14 @@ const CommentButton: FC = ({ {(!recentRepliers || recentRepliers.length === 0) && } {renderRecentRepliers()} -
{renderLabel(messagesCount)}
+
+ {messagesCount ? lang('Comments', messagesCount, 'i') : lang('LeaveAComment')} +
); }; -function renderLabel(messagesCount: number) { - if (messagesCount === 0) { - return 'Leave a Comment'; - } - - if (messagesCount === 1) { - return '1 Comment'; - } - - return `${formatInteger(messagesCount)} Comments`; -} - export default memo(withGlobal( (global, { message }) => { const { threadId, chatId } = message.threadInfo!; diff --git a/src/components/middle/message/Message.tsx b/src/components/middle/message/Message.tsx index e5b52f782..f60d58812 100644 --- a/src/components/middle/message/Message.tsx +++ b/src/components/middle/message/Message.tsx @@ -756,7 +756,7 @@ const Message: FC = ({ color="translucent-white" round size="tiny" - ariaLabel="Forward message" + ariaLabel={lang('lng_context_forward_msg')} onClick={isLastInDocumentGroup ? handleGroupForward : handleForward} > diff --git a/src/components/middle/message/helpers/copyOptions.ts b/src/components/middle/message/helpers/copyOptions.ts index cf0e52212..0314e176e 100644 --- a/src/components/middle/message/helpers/copyOptions.ts +++ b/src/components/middle/message/helpers/copyOptions.ts @@ -21,7 +21,7 @@ export function getMessageCopyOptions( if (canImageBeCopied) { options.push({ - label: 'Copy Media', + label: 'lng_context_copy_image', handler: () => { mediaLoader.fetch(mediaHash, ApiMediaFormat.BlobUrl).then(copyImageToClipboard); @@ -57,7 +57,7 @@ export function getMessageCopyOptions( if (onCopyLink) { options.push({ - label: 'CopyMessageLink', + label: 'lng_context_copy_message_link', handler: () => { onCopyLink(); @@ -73,11 +73,11 @@ export function getMessageCopyOptions( function getCopyLabel(hasSelection: boolean, canImageBeCopied: boolean): string { if (hasSelection) { - return 'Copy Selected Text'; + return 'lng_context_copy_selected'; } if (canImageBeCopied) { - return 'Copy Text'; + return 'lng_context_copy_text'; } return 'Copy'; diff --git a/src/components/right/Profile.tsx b/src/components/right/Profile.tsx index f87eac467..36b771e89 100644 --- a/src/components/right/Profile.tsx +++ b/src/components/right/Profile.tsx @@ -37,6 +37,7 @@ import useProfileViewportIds from './hooks/useProfileViewportIds'; import useProfileState from './hooks/useProfileState'; import useTransitionFixes from './hooks/useTransitionFixes'; import useAsyncRendering from './hooks/useAsyncRendering'; +import useLang from '../../hooks/useLang'; import Transition from '../ui/Transition'; import InfiniteScroll from '../ui/InfiniteScroll'; @@ -120,6 +121,8 @@ const Profile: FC = ({ // eslint-disable-next-line no-null/no-null const transitionRef = useRef(null); + const lang = useLang(); + const [activeTab, setActiveTab] = useState(0); const tabs = useMemo(() => ([ @@ -228,16 +231,16 @@ const Profile: FC = ({ text = areMembersHidden ? 'You have no access to group members list.' : 'No members found'; break; case 'documents': - text = 'No documents found.'; + text = lang('lng_media_file_empty_search'); break; case 'links': - text = 'No links found.'; + text = lang('lng_media_link_empty_search'); break; case 'audio': - text = 'No audio found.'; + text = lang('lng_media_song_empty_search'); break; default: - text = 'No media found.'; + text = lang('SharedMedia.EmptyTitle'); } return ( diff --git a/src/components/right/RightHeader.tsx b/src/components/right/RightHeader.tsx index 1acf9db50..d4afc65d0 100644 --- a/src/components/right/RightHeader.tsx +++ b/src/components/right/RightHeader.tsx @@ -235,7 +235,7 @@ const RightHeader: FC = ({ return ( ); diff --git a/src/components/right/RightSearch.tsx b/src/components/right/RightSearch.tsx index bcc47f8da..49cf3f1ca 100644 --- a/src/components/right/RightSearch.tsx +++ b/src/components/right/RightSearch.tsx @@ -17,6 +17,7 @@ import { isChatChannel, } from '../../modules/helpers'; import renderText from '../common/helpers/renderText'; +import useLang from '../../hooks/useLang'; import { orderBy, pick } from '../../util/iteratees'; import { MEMO_EMPTY_ARRAY } from '../../util/memo'; @@ -60,6 +61,8 @@ const RightSearch: FC = ({ searchTextMessagesLocal, focusMessage, }) => { + const lang = useLang(); + const foundResults = useMemo(() => { if (!query || !foundIds || !foundIds.length || !messagesById) { return MEMO_EMPTY_ARRAY; @@ -98,7 +101,7 @@ const RightSearch: FC = ({ message, senderUser, senderChat, onClick, }: Result) => { const title = senderChat ? getChatTitle(senderChat) : getUserFullName(senderUser); - const text = getMessageSummaryText(message); + const text = getMessageSummaryText(lang, message); return ( diff --git a/src/components/right/StickerSetResult.tsx b/src/components/right/StickerSetResult.tsx index 24a1f2fa3..eccd9157d 100644 --- a/src/components/right/StickerSetResult.tsx +++ b/src/components/right/StickerSetResult.tsx @@ -12,6 +12,7 @@ import { pick } from '../../util/iteratees'; import { selectShouldLoopStickers, selectStickerSet } from '../../modules/selectors'; import useFlag from '../../hooks/useFlag'; import useOnChange from '../../hooks/useOnChange'; +import useLang from '../../hooks/useLang'; import Button from '../ui/Button'; import StickerButton from '../common/StickerButton'; @@ -37,6 +38,7 @@ const STICKERS_TO_DISPLAY = 5; const StickerSetResult: FC = ({ stickerSetId, observeIntersection, set, shouldPlay, loadStickers, toggleStickerSet, isSomeModalOpen, onModalToggle, }) => { + const lang = useLang(); const isAdded = set && Boolean(set.installedDate); const areStickersLoaded = Boolean(set && set.stickers); @@ -79,7 +81,7 @@ const StickerSetResult: FC = ({

{set.title}

-

{set.count} stickers

+

{lang('Stickers', set.count, 'i')}

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