Skip to content

Commit

Permalink
add support for plugin label handler
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Nov 4, 2024
1 parent 7ce9727 commit 52ec4d1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/components/plugin/plugin-label.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Badge } from "@mantine/core";
import { Icon, IconInfoCircle, IconPlugConnected, IconQuestionMark, IconTools, IconUserCog } from "@tabler/icons-react";
import { Icon, IconAffiliate, IconInfoCircle, IconPlugConnected, IconQuestionMark, IconTools, IconUserCog } from "@tabler/icons-react";
import { useTranslations } from "next-intl";
import React from "react";

Expand Down Expand Up @@ -32,12 +32,17 @@ const labelConfigs: LabelConfig[] = [
id: 'api',
color: 'yellow.7',
icon: IconPlugConnected,
}
},
{
id: 'handler',
color: 'violet.5',
icon: IconAffiliate,
},
]

const unknownConfig: LabelConfig = {
id: '__unknown',
color: 'default',
color: 'dark.4',
icon: IconQuestionMark,
}

Expand All @@ -58,6 +63,6 @@ export function PluginLabel({label}: {label: string}) {
size="22"
leftSection={<cfg.icon size={16}/>}
>
{t(cfg.id)}
{cfg === unknownConfig ? `(${t(cfg.id)}) ${label}` : t(cfg.id)}
</Badge >
}
1 change: 1 addition & 0 deletions src/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"tool": "tool",
"management": "management",
"api": "API",
"handler": "handler",
"__unknown": "unknown"
},
"plugin_dependencies": {
Expand Down
1 change: 1 addition & 0 deletions src/messages/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"tool": "工具",
"management": "管理",
"api": "API",
"handler": "服务端处理器",
"__unknown": "未知"
},
"plugin_dependencies": {
Expand Down
1 change: 1 addition & 0 deletions src/site/catalogue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export const pluginLabels: string[] = [
"tool",
"management",
"api",
"handler",
]
3 changes: 3 additions & 0 deletions src/utils/i18n-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const localeToMcdrLang: {[locale: string]: string} = {
}

export function translateLangDict(locale: string, message: LangDict, englishFallback: boolean = true): string | undefined {
if (message === undefined || message === null) {
return undefined
}
const lang = localeToMcdrLang[locale]
if (lang === undefined) {
return undefined
Expand Down

0 comments on commit 52ec4d1

Please sign in to comment.