From 6805c7945d2f38610faeb84448dc8b6801c8e22b Mon Sep 17 00:00:00 2001 From: Emanuele Liardo Date: Sun, 31 Jan 2021 12:29:50 +0100 Subject: [PATCH] fix: translate private chat typing string --- src/Components/Tile/DialogContent.js | 2 +- src/Components/Tile/HeaderChatSubtitle.js | 7 +++--- src/Resources/en/translation.json | 10 ++++++++ src/Resources/it/translation.json | 9 +++++++ src/Utils/Chat.js | 30 +++++++++++------------ 5 files changed, 39 insertions(+), 19 deletions(-) diff --git a/src/Components/Tile/DialogContent.js b/src/Components/Tile/DialogContent.js index 2deefaf3f..2d115ec78 100644 --- a/src/Components/Tile/DialogContent.js +++ b/src/Components/Tile/DialogContent.js @@ -99,7 +99,7 @@ class DialogContent extends React.Component { if (!chat) return
{'\u00A0'}
; let contentControl = null; - const typingString = getChatTypingString(chatId); + const typingString = getChatTypingString(chatId, t); if (typingString) { contentControl = {typingString}; } diff --git a/src/Components/Tile/HeaderChatSubtitle.js b/src/Components/Tile/HeaderChatSubtitle.js index 20a924f1f..09ab08516 100644 --- a/src/Components/Tile/HeaderChatSubtitle.js +++ b/src/Components/Tile/HeaderChatSubtitle.js @@ -8,6 +8,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; +import { withTranslation } from 'react-i18next'; import { getChatSubtitle, isAccentChatSubtitle } from '../../Utils/Chat'; import ChatStore from '../../Stores/ChatStore'; import UserStore from '../../Stores/UserStore'; @@ -155,9 +156,9 @@ class HeaderChatSubtitle extends React.Component { }; render() { - const { chatId } = this.props; + const { chatId, t } = this.props; - const subtitle = getChatSubtitle(chatId, true); + const subtitle = getChatSubtitle(chatId, true, t); const isAccentSubtitle = isAccentChatSubtitle(chatId); return ( @@ -172,4 +173,4 @@ HeaderChatSubtitle.propTypes = { chatId: PropTypes.number.isRequired }; -export default HeaderChatSubtitle; +export default withTranslation()(HeaderChatSubtitle); diff --git a/src/Resources/en/translation.json b/src/Resources/en/translation.json index 65eb2bc74..5fcda121b 100644 --- a/src/Resources/en/translation.json +++ b/src/Resources/en/translation.json @@ -48,6 +48,7 @@ "PaymentsNotSupported": "Sorry, this Telegram client doesn't support payments yet. Please use one of our mobile apps to do this.", "PhoneNumber": "Phone Number", "PhotosTitle": "Photos", + "PlayingAGame": "playing a game", "PollQuizOneRightAnswer": "Quiz has only one right answer.", "PreviewDisabled": "Disabled", "PreviewEnabled": "Enabled", @@ -55,6 +56,9 @@ "Recent": "Frequently Used", "RecordDeniedDescription": "You must allow your browser to access your microphone before being able to record voice notes. Click on the padlock icon next to the URL and then make sure you click Allow in the microphone settings to enable Telegram to access your microphone.", "RecordDeniedTitle": "Permission Denied", + "RecordingAVideo": "recording a video", + "RecordingAVideoMessage": "recording a video message", + "RecordingAVoiceMessage": "recording a voice message", "Saved": "Saved", "Search": "Search", "SearchMessagesIn": "Search messages in", @@ -64,6 +68,11 @@ "SendAsPhoto": "Send as a photo", "SendFileConfirmation": "Are you sure you want to send file?", "SendFilesConfirmation": "Are you sure you want to send files?", + "SendingAFile": "sending a file", + "SendingAPhoto": "sending a photo", + "SendingAVideo": "sending a video", + "SendingAVideoMessage": "sending a video message", + "SendingAVoiceMessage": "sending a voice message", "SendMessage": "Send Message", "SignInToTelegram": "Sign in to Telegram", "SmileysPeople": "Smileys & People", @@ -71,6 +80,7 @@ "Stickers": "STICKERS", "Symbols": "Symbols", "Text": "Text", + "Typing": "typing", "TravelPlaces": "Travel & Places", "UnpinAllMessagesAlert": "Do you want to unpin all messages?", "UpdateDraftConfirmation": "Are you sure you want to update draft?", diff --git a/src/Resources/it/translation.json b/src/Resources/it/translation.json index 874a31a62..48e0cf99c 100644 --- a/src/Resources/it/translation.json +++ b/src/Resources/it/translation.json @@ -45,6 +45,9 @@ "PreviewEnabled": "Attivata", "QRHint": "1. Open Telegram on your phone\n2. Go to Settings > Devices > Scan QR\n3. Scan this image to Log in", "Recent": "Usati di recente", + "RecordingAVideo": "registrando un video", + "RecordingAVideoMessage": "registrando un video messaggio", + "RecordingAVoiceMessage": "registrando un messaggio vocale", "Saved": "Messaggi salvati", "Search": "Cerca", "SearchMessagesIn": "Cerca messaggi in", @@ -54,6 +57,11 @@ "SendAsPhoto": "Invia come immagine", "SendFileConfirmation": "Sei sicuro di voler mandare il file?", "SendFilesConfirmation": "Sei sicuro di voler mandare i file?", + "SendingAFile": "inviando un file", + "SendingAPhoto": "inviando una foto", + "SendingAVideo": "inviando un video", + "SendingAVideoMessage": "inviando un video messaggio", + "SendingAVoiceMessage": "inviando un messaggio vocale", "SendMessage": "Invia messaggio", "SignInToTelegram": "Accedi a Telegram", "SmileysPeople": "Faccine e Persone", @@ -61,6 +69,7 @@ "Stickers": "STICKER", "Symbols": "Simboli", "Text": "Testo", + "Typing": "Sta scrivendo", "TravelPlaces": "Viaggi e Luoghi", "UpdateDraftConfirmation": "Sei sicuro di voler aggiornare la bozza?", "Updating": "Aggiorno...", diff --git a/src/Utils/Chat.js b/src/Utils/Chat.js index f7fef8da1..3d1ed0685 100644 --- a/src/Utils/Chat.js +++ b/src/Utils/Chat.js @@ -380,42 +380,42 @@ function getGroupChatTypingString(inputTypingManager) { return null; } -function getPrivateChatTypingString(inputTypingManager) { +function getPrivateChatTypingString(inputTypingManager, t = x => x) { if (!inputTypingManager) return null; if (inputTypingManager.actions.size >= 1) { let action = inputTypingManager.actions.values().next().value.action; switch (action['@type']) { case 'chatActionRecordingVideo': - return 'recording a video'; + return t('RecordingAVideo'); case 'chatActionRecordingVideoNote': - return 'recording a video message'; + return t('RecordingAVideoMessage'); case 'chatActionRecordingVoiceNote': - return 'recording a voice message'; + return t('RecordingAVoiceMessage'); case 'chatActionStartPlayingGame': - return 'playing a game'; + return t('PlayingAGame'); case 'chatActionUploadingDocument': - return 'sending a file'; + return t('SendingAFile'); case 'chatActionUploadingPhoto': - return 'sending a photo'; + return t('SendingAPhoto'); case 'chatActionUploadingVideo': - return 'sending a video'; + return t('SendingAVideo'); case 'chatActionUploadingVideoNote': - return 'sending a video message'; + return t('SendingAVideoMessage'); case 'chatActionUploadingVoiceNote': - return 'sending a voice message'; + return t('SendingAVoiceMessage'); case 'chatActionChoosingContact': case 'chatActionChoosingLocation': case 'chatActionTyping': default: - return 'typing'; + return t('Typing'); } } return null; } -function getChatTypingString(chatId) { +function getChatTypingString(chatId, t) { const chat = ChatStore.get(chatId); if (!chat) return null; if (!chat.type) return null; @@ -426,7 +426,7 @@ function getChatTypingString(chatId) { switch (chat.type['@type']) { case 'chatTypePrivate': case 'chatTypeSecret': { - const typingString = getPrivateChatTypingString(typingManager); + const typingString = getPrivateChatTypingString(typingManager, t); return typingString ? typingString + '...' : null; } case 'chatTypeBasicGroup': @@ -667,12 +667,12 @@ function getChatSubtitleWithoutTyping(chatId) { return null; } -function getChatSubtitle(chatId, showSavedMessages = false) { +function getChatSubtitle(chatId, showSavedMessages = false, t) { if (isMeChat(chatId) && showSavedMessages) { return null; } - const chatTypingString = getChatTypingString(chatId); + const chatTypingString = getChatTypingString(chatId, t); if (chatTypingString) { return chatTypingString; }