diff --git a/client/web/plugins/com.msgbyte.notify/src/index.tsx b/client/web/plugins/com.msgbyte.notify/src/index.tsx index 84821359..f0fac147 100644 --- a/client/web/plugins/com.msgbyte.notify/src/index.tsx +++ b/client/web/plugins/com.msgbyte.notify/src/index.tsx @@ -2,23 +2,26 @@ import { regGroupPanelBadge, regPluginGroupTextPanelExtraMenu, sharedEvent, + showToasts, } from '@capital/common'; import { Icon } from '@capital/component'; import React from 'react'; import { appendSilent, hasSilent, removeSilent } from './silent'; import { initNotify } from './notify'; +import { Translate } from './translate'; const PLUGIN_NAME = 'com.msgbyte.notify'; if ('Notification' in window) { initNotify(); } else { - console.warn('浏览器不支持 Notification'); + showToasts(Translate.nosupport, 'warning'); + console.warn(Translate.nosupport); } regPluginGroupTextPanelExtraMenu({ name: `${PLUGIN_NAME}/grouppanelmenu`, - label: '免打扰', + label: Translate.slient, icon: 'mdi:bell-off-outline', onClick: (panelInfo) => { if (hasSilent(panelInfo.id)) { diff --git a/client/web/plugins/com.msgbyte.notify/src/notify.ts b/client/web/plugins/com.msgbyte.notify/src/notify.ts index 048d1392..c35d958b 100644 --- a/client/web/plugins/com.msgbyte.notify/src/notify.ts +++ b/client/web/plugins/com.msgbyte.notify/src/notify.ts @@ -4,6 +4,7 @@ import { getCachedUserInfo, getServiceWorkerRegistration, } from '@capital/common'; +import { Translate } from './translate'; import { hasSilent } from './silent'; export function initNotify() { @@ -37,7 +38,7 @@ export function initNotify() { getServiceWorkerRegistration(); if (registration) { - registration.showNotification(`来自 ${nickname}`, { + registration.showNotification(`${Translate.from} ${nickname}`, { body: content, icon, tag: 'tailchat-message', @@ -45,7 +46,7 @@ export function initNotify() { }); } else { // fallback - new Notification(`来自 ${nickname}`, { + new Notification(`${Translate.from} ${nickname}`, { body: content, icon, tag: 'tailchat-message', diff --git a/client/web/plugins/com.msgbyte.notify/src/translate.ts b/client/web/plugins/com.msgbyte.notify/src/translate.ts new file mode 100644 index 00000000..89adea9c --- /dev/null +++ b/client/web/plugins/com.msgbyte.notify/src/translate.ts @@ -0,0 +1,13 @@ +import { localTrans } from '@capital/common'; + +export const Translate = { + nosupport: localTrans({ + 'zh-CN': '当前浏览器不支持 Notification', + 'en-US': 'This browser not support Notification', + }), + slient: localTrans({ 'zh-CN': '免打扰', 'en-US': 'Slient' }), + from: localTrans({ + 'zh-CN': '来自', + 'en-US': 'From', + }), +};