Make sure screen name is internationalized

This commit is contained in:
Fedor Indutny
2021-06-03 11:42:30 -07:00
committed by GitHub
parent 84aed82357
commit 56f0e1ba46
3 changed files with 54 additions and 8 deletions

View File

@@ -48,6 +48,7 @@ import {
PresentableSource,
PresentedSource,
} from '../types/Calling';
import { LocalizerType } from '../types/Util';
import { ConversationModel } from '../models/conversations';
import {
base64ToArrayBuffer,
@@ -89,6 +90,33 @@ enum GroupCallUpdateMessageState {
SentLeft,
}
export function isScreenSource(source: PresentedSource): boolean {
return source.id.startsWith('screen');
}
export function translateSourceName(
i18n: LocalizerType,
source: PresentedSource
): string {
const { name } = source;
if (!isScreenSource(source)) {
return name;
}
if (name === 'Entire Screen') {
return i18n('calling__SelectPresentingSourcesModal--entireScreen');
}
const match = name.match(/^Screen (\d+)$/);
if (match) {
return i18n('calling__SelectPresentingSourcesModal--screen', {
id: match[1],
});
}
return name;
}
export class CallingClass {
readonly videoCapturer: GumVideoCapturer;
@@ -954,7 +982,10 @@ export class CallingClass {
this.setOutgoingVideoIsScreenShare(call, isPresenting);
if (source) {
ipcRenderer.send('show-screen-share', source.name);
ipcRenderer.send(
'show-screen-share',
translateSourceName(window.i18n, source)
);
notify({
icon: 'images/icons/v2/video-solid-24.svg',
message: window.i18n('calling__presenting--notification-body'),