mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-08 02:52:07 +08:00
chore: update i18n
This commit is contained in:
@@ -583,7 +583,7 @@ export function DnsViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
setOpen(false)
|
||||
showNotice.success('settings.modals.dns.messages.saved')
|
||||
} catch (err) {
|
||||
showNotice.error(err)
|
||||
showNotice.error('settings.modals.dns.messages.configError', err)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -30,11 +30,26 @@ type MarkdownNode = {
|
||||
}
|
||||
|
||||
const GITHUB_ALERTS = {
|
||||
note: { label: 'Note', color: '#0969da' },
|
||||
tip: { label: 'Tip', color: '#1a7f37' },
|
||||
important: { label: 'Important', color: '#8250df' },
|
||||
warning: { label: 'Warning', color: '#9a6700' },
|
||||
caution: { label: 'Caution', color: '#cf222e' },
|
||||
note: {
|
||||
labelKey: 'settings.modals.update.alerts.note',
|
||||
color: '#0969da',
|
||||
},
|
||||
tip: {
|
||||
labelKey: 'settings.modals.update.alerts.tip',
|
||||
color: '#1a7f37',
|
||||
},
|
||||
important: {
|
||||
labelKey: 'settings.modals.update.alerts.important',
|
||||
color: '#8250df',
|
||||
},
|
||||
warning: {
|
||||
labelKey: 'settings.modals.update.alerts.warning',
|
||||
color: '#9a6700',
|
||||
},
|
||||
caution: {
|
||||
labelKey: 'settings.modals.update.alerts.caution',
|
||||
color: '#cf222e',
|
||||
},
|
||||
} as const
|
||||
|
||||
type GitHubAlertType = keyof typeof GITHUB_ALERTS
|
||||
@@ -76,7 +91,7 @@ const findFirstTextNode = (node: MarkdownNode): MarkdownNode | null => {
|
||||
return null
|
||||
}
|
||||
|
||||
const remarkGitHubAlerts = () => {
|
||||
const remarkGitHubAlerts = (labels: Record<GitHubAlertType, string>) => {
|
||||
const visit = (node: MarkdownNode) => {
|
||||
for (const child of node.children ?? []) {
|
||||
visit(child)
|
||||
@@ -111,7 +126,7 @@ const remarkGitHubAlerts = () => {
|
||||
children: [
|
||||
{
|
||||
type: 'text',
|
||||
value: GITHUB_ALERTS[alertType].label,
|
||||
value: labels[alertType],
|
||||
},
|
||||
],
|
||||
})
|
||||
@@ -144,12 +159,27 @@ export function UpdateViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
close: () => setOpen(false),
|
||||
}))
|
||||
|
||||
const githubAlertLabels = useMemo(
|
||||
() =>
|
||||
Object.fromEntries(
|
||||
Object.entries(GITHUB_ALERTS).map(([type, alert]) => [
|
||||
type,
|
||||
t(alert.labelKey),
|
||||
]),
|
||||
) as Record<GitHubAlertType, string>,
|
||||
[t],
|
||||
)
|
||||
const remarkGitHubAlertsPlugin = useMemo(
|
||||
() => () => remarkGitHubAlerts(githubAlertLabels),
|
||||
[githubAlertLabels],
|
||||
)
|
||||
|
||||
const markdownContent = useMemo(() => {
|
||||
if (!updateInfo?.body) {
|
||||
return 'New Version is available'
|
||||
return t('settings.modals.update.messages.available')
|
||||
}
|
||||
return updateInfo?.body
|
||||
}, [updateInfo])
|
||||
}, [t, updateInfo])
|
||||
|
||||
const breakChangeFlag = useMemo(() => {
|
||||
if (!updateInfo?.body) {
|
||||
@@ -382,7 +412,7 @@ export function UpdateViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
{open && (
|
||||
<Suspense fallback={<LinearProgress />}>
|
||||
<LazyReactMarkdown
|
||||
remarkPlugins={[remarkGitHubAlerts]}
|
||||
remarkPlugins={[remarkGitHubAlertsPlugin]}
|
||||
components={{
|
||||
a: ({ ...props }) => {
|
||||
const { children } = props
|
||||
|
||||
@@ -74,9 +74,17 @@ export function WebUIViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
let url = value.trim().replaceAll('%host', '127.0.0.1')
|
||||
|
||||
if (url.includes('%port') || url.includes('%secret')) {
|
||||
if (!clashInfo) throw new Error('failed to get clash info')
|
||||
if (!clashInfo) {
|
||||
throw new Error(
|
||||
t('settings.modals.webUI.errors.clashInfoUnavailable'),
|
||||
)
|
||||
}
|
||||
if (!clashInfo.server?.includes(':')) {
|
||||
throw new Error(`failed to parse the server "${clashInfo.server}"`)
|
||||
throw new Error(
|
||||
t('settings.modals.webUI.errors.invalidServer', {
|
||||
server: clashInfo.server,
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
const port = clashInfo.server
|
||||
@@ -92,7 +100,7 @@ export function WebUIViewer({ ref }: { ref?: Ref<DialogRef> }) {
|
||||
|
||||
await openWebUrl(url)
|
||||
} catch (e: any) {
|
||||
showNotice.error(e)
|
||||
showNotice.error('settings.modals.webUI.errors.openFailed', e)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user