Skip to content

Commit b7feabb

Browse files
committed
feat: 声网插件增加国际化支持
1 parent 5b7e767 commit b7feabb

File tree

6 files changed

+62
-11
lines changed

6 files changed

+62
-11
lines changed

server/plugins/com.msgbyte.agora/web/plugins/com.msgbyte.agora/src/FloatWindow/Controls.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useAsyncFn } from '@capital/common';
22
import { IconBtn } from '@capital/component';
33
import React from 'react';
4+
import { Translate } from '../translate';
45
import {
56
useClient,
67
createMicrophoneAudioTrack,
@@ -61,7 +62,7 @@ export const Controls: React.FC<{
6162
<div className="controller">
6263
<IconBtn
6364
icon={mediaPerm.video ? 'mdi:video' : 'mdi:video-off'}
64-
title={mediaPerm.video ? '关闭摄像头' : '开启摄像头'}
65+
title={mediaPerm.video ? Translate.closeCamera : Translate.openCamera}
6566
active={mediaPerm.video}
6667
disabled={loading}
6768
size="large"
@@ -70,7 +71,7 @@ export const Controls: React.FC<{
7071

7172
<IconBtn
7273
icon={mediaPerm.audio ? 'mdi:microphone' : 'mdi:microphone-off'}
73-
title={mediaPerm.audio ? '关闭麦克风' : '开启麦克风'}
74+
title={mediaPerm.audio ? Translate.closeMic : Translate.openMic}
7475
active={mediaPerm.audio}
7576
disabled={loading}
7677
size="large"
@@ -79,7 +80,7 @@ export const Controls: React.FC<{
7980

8081
<IconBtn
8182
icon="mdi:phone-remove-outline"
82-
title="挂断"
83+
title={Translate.hangUp}
8384
danger={true}
8485
size="large"
8586
onClick={leaveChannel}

server/plugins/com.msgbyte.agora/web/plugins/com.msgbyte.agora/src/FloatWindow/MeetingView.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useMeetingStore } from './store';
1111
import { NetworkStats } from './NetworkStats';
1212
import _once from 'lodash/once';
1313
import type { IAgoraRTCClient } from 'agora-rtc-react';
14+
import { Translate } from '../translate';
1415

1516
const Root = styled.div`
1617
.body {
@@ -113,7 +114,7 @@ export const MeetingView: React.FC<MeetingViewProps> = React.memo((props) => {
113114
<NetworkStats />
114115

115116
<div className="body">
116-
{start ? <Videos /> : <LoadingSpinner tip={'正在加入通话...'} />}
117+
{start ? <Videos /> : <LoadingSpinner tip={Translate.joinTip} />}
117118
</div>
118119

119120
<div className="controller">

server/plugins/com.msgbyte.agora/web/plugins/com.msgbyte.agora/src/FloatWindow/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
import { showToasts } from '@capital/common';
22
import { PortalAdd, PortalRemove } from '@capital/component';
33
import React from 'react';
4+
import { Translate } from '../translate';
45
import { FloatMeetingWindow } from './window';
56

67
let currentMeeting: string | null = null;
78

89
/**
9-
* TODO
10-
*
1110
* 启动快速会议
1211
*
1312
* 表现形式是在浏览器内有个小的浮动窗口
1413
*/
1514
export function startFastMeeting(meetingId: string) {
1615
if (currentMeeting) {
17-
showToasts('当前已有正在进行中的通话, 请先结束上一场通话');
16+
showToasts(Translate.repeatTip);
1817
return;
1918
}
2019

server/plugins/com.msgbyte.agora/web/plugins/com.msgbyte.agora/src/FloatWindow/window.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import styled from 'styled-components';
33
import { Divider, ErrorBoundary } from '@capital/component';
44
import { MeetingView, MeetingViewProps } from './MeetingView';
55
import { SpeakerNames } from './SpeakerNames';
6+
import { Translate } from '../translate';
67

78
const FloatWindow = styled.div`
89
z-index: 100;
@@ -61,7 +62,9 @@ export const FloatMeetingWindow: React.FC<MeetingViewProps> = React.memo(
6162

6263
<Divider type="vertical" />
6364

64-
<span style={{ marginLeft: 4 }}>{folder ? '展开' : '收起'}</span>
65+
<span style={{ marginLeft: 4 }}>
66+
{folder ? Translate.expand : Translate.foldup}
67+
</span>
6568
</div>
6669
</div>
6770
</FloatWindow>

server/plugins/com.msgbyte.agora/web/plugins/com.msgbyte.agora/src/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { regPluginPanelAction } from '@capital/common';
22
import { openConfirmModal } from '@capital/component';
3+
import { Translate } from './translate';
34

45
console.log('Plugin 声网音视频 is loaded');
56

@@ -11,13 +12,13 @@ async function startFastMeeting(meetingId: string) {
1112
// 发起群组会议
1213
regPluginPanelAction({
1314
name: 'plugin:com.msgbyte.meeting/groupAction',
14-
label: '发起通话',
15+
label: Translate.startCall,
1516
position: 'group',
1617
icon: 'mdi:video-box',
1718
onClick: ({ groupId, panelId }) => {
1819
openConfirmModal({
19-
title: '发起通话',
20-
content: '是否通过声网插件在当前会话开启音视频通讯?',
20+
title: Translate.startCall,
21+
content: Translate.startCallContent,
2122
onConfirm: async () => {
2223
startFastMeeting(`${groupId}|${panelId}`);
2324
},

server/plugins/com.msgbyte.agora/web/plugins/com.msgbyte.agora/src/translate.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,50 @@ export const Translate = {
1717
'zh-CN': '无人发言',
1818
'en-US': 'No one Speaking',
1919
}),
20+
startCall: localTrans({
21+
'zh-CN': '发起通话',
22+
'en-US': 'Start Call',
23+
}),
24+
startCallContent: localTrans({
25+
'zh-CN': '是否通过声网插件在当前会话开启音视频通讯?',
26+
'en-US':
27+
'Do you want to enable audio and video communication in the current session through the Agora plugin?',
28+
}),
29+
expand: localTrans({
30+
'zh-CN': '展开',
31+
'en-US': 'expand',
32+
}),
33+
foldup: localTrans({
34+
'zh-CN': '收起',
35+
'en-US': 'foldup',
36+
}),
37+
joinTip: localTrans({
38+
'zh-CN': '正在加入通话...',
39+
'en-US': 'Joining call...',
40+
}),
41+
repeatTip: localTrans({
42+
'zh-CN': '当前已有正在进行中的通话, 请先结束上一场通话',
43+
'en-US':
44+
'There is currently an active call, please end the previous call first',
45+
}),
46+
hangUp: localTrans({
47+
'zh-CN': '挂断',
48+
'en-US': 'Hang Up',
49+
}),
50+
openCamera: localTrans({
51+
'zh-CN': '开启摄像头',
52+
'en-US': 'Open Camera',
53+
}),
54+
closeCamera: localTrans({
55+
'zh-CN': '关闭摄像头',
56+
'en-US': 'Close Camera',
57+
}),
58+
openMic: localTrans({
59+
'zh-CN': '开启麦克风',
60+
'en-US': 'Open Mic',
61+
}),
62+
closeMic: localTrans({
63+
'zh-CN': '关闭麦克风',
64+
'en-US': 'Close Mic',
65+
}),
2066
};

0 commit comments

Comments
 (0)