Skip to content

Commit 3569f0e

Browse files
authored
Merge pull request #2440 from mysubcult/widget/voice-timer-i18n
Widget voice message: readable, translatable timer
2 parents aedba57 + 48663b8 commit 3569f0e

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎lhc_web/design/defaulttheme/widget/react-app/src/components/VoiceMessage.js‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,11 @@ class VoiceMessage extends PureComponent {
515515
return (n < 10) ? ("0" + n) : n;
516516
}
517517

518+
formatTime(seconds) {
519+
seconds = Math.max(0, parseInt(seconds, 10) || 0);
520+
return Math.floor(seconds / 60) + ':' + this.pad(seconds % 60);
521+
}
522+
518523
render() {
519524

520525
const {isLoading, isRecording, recording, isPlaying, isTranscribing } = this.state;
@@ -540,7 +545,7 @@ class VoiceMessage extends PureComponent {
540545

541546
{isRecording && <span className="voice-message-level" ref={this.levelRef} aria-hidden="true">{Array.from({length: 24}, (v, i) => <i key={i}></i>)}</span>}
542547

543-
<span className="fs12 px-1 voice-message-length">{isRecording ? '' : (isPlaying ? this.pad(this.state.currentTime) + ':' : '')}{isRecording || !recording ? (this.props.maxSeconds - this.state.audioDuration) + " s." : this.pad(this.state.audioDuration) + (!isPlaying ? 's.' : '')}</span>
548+
<span className="fs12 px-1 voice-message-length">{isRecording ? this.formatTime(this.state.audioDuration) + ' / ' + this.formatTime(this.props.maxSeconds) : (recording ? (isPlaying ? this.formatTime(this.state.currentTime) + ' / ' : '') + this.formatTime(this.state.audioDuration) : t('voice.up_to', {time: this.formatTime(this.props.maxSeconds)}))}</span>
544549

545550
{recording && <button type="button" tabIndex="0" className="material-icons material-icons-button pointer text-success me-0 fs25" title={t('voice.send')} onClick={this.sendRecord}>&#xf107;</button>}
546551

‎lhc_web/modules/lhwidgetrestapi/lang.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@
103103
"stop_playing_recorded" => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Stop playing recorded audio'),
104104
"send" => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Send voice message'),
105105
"dictate" => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Dictate'),
106-
"stop_dictate" => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Stop')
106+
"stop_dictate" => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Stop'),
107+
"up_to" => erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Up to {{time}}')
107108
]
108109
);
109110

‎lhc_web/translations/ru_RU/translation.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9210,6 +9210,10 @@
92109210
<source>Cancel voice message</source>
92119211
<translation>Отмена голосового сообщения</translation>
92129212
</message>
9213+
<message>
9214+
<source>Up to {{time}}</source>
9215+
<translation>До {{time}}</translation>
9216+
</message>
92139217
<message>
92149218
<source>Play recorded message</source>
92159219
<translation>Воспроизвести записанное сообщение</translation>

0 commit comments

Comments
 (0)