Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: translate private chat typing string #352

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Components/Tile/DialogContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class DialogContent extends React.Component {
if (!chat) return <div className='dialog-content'>{'\u00A0'}</div>;

let contentControl = null;
const typingString = getChatTypingString(chatId);
const typingString = getChatTypingString(chatId, t);
if (typingString) {
contentControl = <span className='dialog-content-accent'>{typingString}</span>;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Components/Tile/HeaderChatSubtitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 (
Expand All @@ -172,4 +173,4 @@ HeaderChatSubtitle.propTypes = {
chatId: PropTypes.number.isRequired
};

export default HeaderChatSubtitle;
export default withTranslation()(HeaderChatSubtitle);
10 changes: 10 additions & 0 deletions src/Resources/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,17 @@
"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",
"QRHint": "1. Open Telegram on your phone\n2. Go to Settings > Devices > Scan QR\n3. Scan this image to Log in",
"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",
Expand All @@ -64,13 +68,19 @@
"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",
"StartText": "Please confirm your country code and enter your phone number.",
"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?",
Expand Down
9 changes: 9 additions & 0 deletions src/Resources/it/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -54,13 +57,19 @@
"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",
"StartText": "Conferma il prefisso internazionale e inserisci il tuo numero di telefono.",
"Stickers": "STICKER",
"Symbols": "Simboli",
"Text": "Testo",
"Typing": "Sta scrivendo",
"TravelPlaces": "Viaggi e Luoghi",
"UpdateDraftConfirmation": "Sei sicuro di voler aggiornare la bozza?",
"Updating": "Aggiorno...",
Expand Down
30 changes: 15 additions & 15 deletions src/Utils/Chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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':
Expand Down Expand Up @@ -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;
}
Expand Down