feat: 声网插件增加国际化支持

pull/64/head
moonrailgun 2 years ago
parent 5b7e767e40
commit b7feabbbd3

@ -1,6 +1,7 @@
import { useAsyncFn } from '@capital/common'; import { useAsyncFn } from '@capital/common';
import { IconBtn } from '@capital/component'; import { IconBtn } from '@capital/component';
import React from 'react'; import React from 'react';
import { Translate } from '../translate';
import { import {
useClient, useClient,
createMicrophoneAudioTrack, createMicrophoneAudioTrack,
@ -61,7 +62,7 @@ export const Controls: React.FC<{
<div className="controller"> <div className="controller">
<IconBtn <IconBtn
icon={mediaPerm.video ? 'mdi:video' : 'mdi:video-off'} icon={mediaPerm.video ? 'mdi:video' : 'mdi:video-off'}
title={mediaPerm.video ? '关闭摄像头' : '开启摄像头'} title={mediaPerm.video ? Translate.closeCamera : Translate.openCamera}
active={mediaPerm.video} active={mediaPerm.video}
disabled={loading} disabled={loading}
size="large" size="large"
@ -70,7 +71,7 @@ export const Controls: React.FC<{
<IconBtn <IconBtn
icon={mediaPerm.audio ? 'mdi:microphone' : 'mdi:microphone-off'} icon={mediaPerm.audio ? 'mdi:microphone' : 'mdi:microphone-off'}
title={mediaPerm.audio ? '关闭麦克风' : '开启麦克风'} title={mediaPerm.audio ? Translate.closeMic : Translate.openMic}
active={mediaPerm.audio} active={mediaPerm.audio}
disabled={loading} disabled={loading}
size="large" size="large"
@ -79,7 +80,7 @@ export const Controls: React.FC<{
<IconBtn <IconBtn
icon="mdi:phone-remove-outline" icon="mdi:phone-remove-outline"
title="挂断" title={Translate.hangUp}
danger={true} danger={true}
size="large" size="large"
onClick={leaveChannel} onClick={leaveChannel}

@ -11,6 +11,7 @@ import { useMeetingStore } from './store';
import { NetworkStats } from './NetworkStats'; import { NetworkStats } from './NetworkStats';
import _once from 'lodash/once'; import _once from 'lodash/once';
import type { IAgoraRTCClient } from 'agora-rtc-react'; import type { IAgoraRTCClient } from 'agora-rtc-react';
import { Translate } from '../translate';
const Root = styled.div` const Root = styled.div`
.body { .body {
@ -113,7 +114,7 @@ export const MeetingView: React.FC<MeetingViewProps> = React.memo((props) => {
<NetworkStats /> <NetworkStats />
<div className="body"> <div className="body">
{start ? <Videos /> : <LoadingSpinner tip={'正在加入通话...'} />} {start ? <Videos /> : <LoadingSpinner tip={Translate.joinTip} />}
</div> </div>
<div className="controller"> <div className="controller">

@ -1,20 +1,19 @@
import { showToasts } from '@capital/common'; import { showToasts } from '@capital/common';
import { PortalAdd, PortalRemove } from '@capital/component'; import { PortalAdd, PortalRemove } from '@capital/component';
import React from 'react'; import React from 'react';
import { Translate } from '../translate';
import { FloatMeetingWindow } from './window'; import { FloatMeetingWindow } from './window';
let currentMeeting: string | null = null; let currentMeeting: string | null = null;
/** /**
* TODO
*
* *
* *
* *
*/ */
export function startFastMeeting(meetingId: string) { export function startFastMeeting(meetingId: string) {
if (currentMeeting) { if (currentMeeting) {
showToasts('当前已有正在进行中的通话, 请先结束上一场通话'); showToasts(Translate.repeatTip);
return; return;
} }

@ -3,6 +3,7 @@ import styled from 'styled-components';
import { Divider, ErrorBoundary } from '@capital/component'; import { Divider, ErrorBoundary } from '@capital/component';
import { MeetingView, MeetingViewProps } from './MeetingView'; import { MeetingView, MeetingViewProps } from './MeetingView';
import { SpeakerNames } from './SpeakerNames'; import { SpeakerNames } from './SpeakerNames';
import { Translate } from '../translate';
const FloatWindow = styled.div` const FloatWindow = styled.div`
z-index: 100; z-index: 100;
@ -61,7 +62,9 @@ export const FloatMeetingWindow: React.FC<MeetingViewProps> = React.memo(
<Divider type="vertical" /> <Divider type="vertical" />
<span style={{ marginLeft: 4 }}>{folder ? '展开' : '收起'}</span> <span style={{ marginLeft: 4 }}>
{folder ? Translate.expand : Translate.foldup}
</span>
</div> </div>
</div> </div>
</FloatWindow> </FloatWindow>

@ -1,5 +1,6 @@
import { regPluginPanelAction } from '@capital/common'; import { regPluginPanelAction } from '@capital/common';
import { openConfirmModal } from '@capital/component'; import { openConfirmModal } from '@capital/component';
import { Translate } from './translate';
console.log('Plugin 声网音视频 is loaded'); console.log('Plugin 声网音视频 is loaded');
@ -11,13 +12,13 @@ async function startFastMeeting(meetingId: string) {
// 发起群组会议 // 发起群组会议
regPluginPanelAction({ regPluginPanelAction({
name: 'plugin:com.msgbyte.meeting/groupAction', name: 'plugin:com.msgbyte.meeting/groupAction',
label: '发起通话', label: Translate.startCall,
position: 'group', position: 'group',
icon: 'mdi:video-box', icon: 'mdi:video-box',
onClick: ({ groupId, panelId }) => { onClick: ({ groupId, panelId }) => {
openConfirmModal({ openConfirmModal({
title: '发起通话', title: Translate.startCall,
content: '是否通过声网插件在当前会话开启音视频通讯?', content: Translate.startCallContent,
onConfirm: async () => { onConfirm: async () => {
startFastMeeting(`${groupId}|${panelId}`); startFastMeeting(`${groupId}|${panelId}`);
}, },

@ -17,4 +17,50 @@ export const Translate = {
'zh-CN': '无人发言', 'zh-CN': '无人发言',
'en-US': 'No one Speaking', 'en-US': 'No one Speaking',
}), }),
startCall: localTrans({
'zh-CN': '发起通话',
'en-US': 'Start Call',
}),
startCallContent: localTrans({
'zh-CN': '是否通过声网插件在当前会话开启音视频通讯?',
'en-US':
'Do you want to enable audio and video communication in the current session through the Agora plugin?',
}),
expand: localTrans({
'zh-CN': '展开',
'en-US': 'expand',
}),
foldup: localTrans({
'zh-CN': '收起',
'en-US': 'foldup',
}),
joinTip: localTrans({
'zh-CN': '正在加入通话...',
'en-US': 'Joining call...',
}),
repeatTip: localTrans({
'zh-CN': '当前已有正在进行中的通话, 请先结束上一场通话',
'en-US':
'There is currently an active call, please end the previous call first',
}),
hangUp: localTrans({
'zh-CN': '挂断',
'en-US': 'Hang Up',
}),
openCamera: localTrans({
'zh-CN': '开启摄像头',
'en-US': 'Open Camera',
}),
closeCamera: localTrans({
'zh-CN': '关闭摄像头',
'en-US': 'Close Camera',
}),
openMic: localTrans({
'zh-CN': '开启麦克风',
'en-US': 'Open Mic',
}),
closeMic: localTrans({
'zh-CN': '关闭麦克风',
'en-US': 'Close Mic',
}),
}; };

Loading…
Cancel
Save