fix: localize agnet role and resource labels

This commit is contained in:
gongzhiyong
2026-05-28 18:51:43 +08:00
parent 587746db90
commit 53cc1a5e63
3 changed files with 69 additions and 9 deletions
+1 -1
View File
@@ -1 +1 @@
1.4.14 1.4.15
@@ -245,6 +245,46 @@ function formatSubMode(value: AgnetSubMode, t: (key: string) => string) {
return t('Waterfall') return t('Waterfall')
} }
function formatRoleLabel(value: string, t: (key: string) => string) {
const role = value.trim().toLowerCase()
const labels: Record<string, string> = {
product: t('Product role'),
frontend: t('Frontend role'),
backend: t('Backend role'),
reviewer: t('Reviewer role'),
ops: t('Ops role'),
builder: t('Builder role'),
}
return labels[role] || value
}
function formatRoleDisplayName(value: string, t: (key: string) => string) {
const name = value.trim().toLowerCase()
const labels: Record<string, string> = {
'product agnet': t('Product Agnet'),
'frontend agnet': t('Frontend Agnet'),
'backend agnet': t('Backend Agnet'),
'reviewer agnet': t('Reviewer Agnet'),
'ops agnet': t('Ops Agnet'),
}
return labels[name] || value
}
function formatResourceType(
value: ResourceType | string,
t: (key: string) => string
) {
const type = String(value).trim().toLowerCase()
const labels: Record<string, string> = {
git: t('Git repository'),
sk: t('SK skill pack'),
project_doc: t('Project docs'),
cloud_account: t('Cloud account'),
cloud_resource: t('Cloud resource'),
}
return labels[type] || String(value)
}
function buildAgent( function buildAgent(
row: AgentFormRow, row: AgentFormRow,
index: number, index: number,
@@ -936,7 +976,9 @@ export function CreateAgnetDeploymentSheet({
<div className='flex items-center gap-2'> <div className='flex items-center gap-2'>
<Badge variant='secondary'>#{index + 1}</Badge> <Badge variant='secondary'>#{index + 1}</Badge>
<span className='text-sm font-medium'> <span className='text-sm font-medium'>
{agent.role_template || t('Agent')} {agent.role_template
? formatRoleLabel(agent.role_template, t)
: t('Agent')}
</span> </span>
</div> </div>
{agents.length > 1 ? ( {agents.length > 1 ? (
@@ -976,9 +1018,9 @@ export function CreateAgnetDeploymentSheet({
<SelectContent> <SelectContent>
{roleTemplates.map((tpl) => ( {roleTemplates.map((tpl) => (
<SelectItem key={tpl.key} value={tpl.key}> <SelectItem key={tpl.key} value={tpl.key}>
<span className='font-mono'>{tpl.key}</span> <span>{formatRoleLabel(tpl.key, t)}</span>
<span className='text-muted-foreground ml-2'> <span className='text-muted-foreground ml-2'>
· {tpl.display_name} · {formatRoleDisplayName(tpl.display_name, t)}
</span> </span>
</SelectItem> </SelectItem>
))} ))}
@@ -1052,7 +1094,7 @@ export function CreateAgnetDeploymentSheet({
<SelectContent> <SelectContent>
{RESOURCE_TYPES.map((type) => ( {RESOURCE_TYPES.map((type) => (
<SelectItem key={type} value={type}> <SelectItem key={type} value={type}>
{type} {formatResourceType(type, t)}
</SelectItem> </SelectItem>
))} ))}
</SelectContent> </SelectContent>
@@ -1276,7 +1318,7 @@ export function CreateAgnetDeploymentSheet({
key={a.role} key={a.role}
className='text-primary inline-flex items-center gap-1 rounded-md bg-[color-mix(in_oklch,var(--primary)_12%,transparent)] px-1.5 py-0.5 font-mono text-[10px]' className='text-primary inline-flex items-center gap-1 rounded-md bg-[color-mix(in_oklch,var(--primary)_12%,transparent)] px-1.5 py-0.5 font-mono text-[10px]'
> >
{a.role} {formatRoleLabel(a.role, t)}
<span className='text-muted-foreground'>·</span> <span className='text-muted-foreground'>·</span>
{a.model_ref} {a.model_ref}
</span> </span>
@@ -1309,8 +1351,11 @@ export function CreateAgnetDeploymentSheet({
className='flex items-center gap-2' className='flex items-center gap-2'
> >
<span className='text-primary inline-flex items-center rounded bg-[color-mix(in_oklch,var(--primary)_10%,transparent)] px-1 font-mono text-[10px]'> <span className='text-primary inline-flex items-center rounded bg-[color-mix(in_oklch,var(--primary)_10%,transparent)] px-1 font-mono text-[10px]'>
{(g as { resource_type?: string }) {formatResourceType(
.resource_type || '?'} (g as { resource_type?: string })
.resource_type || '?',
t
)}
</span> </span>
<span className='text-muted-foreground font-mono text-[11px]'> <span className='text-muted-foreground font-mono text-[11px]'>
{(g as { resource_id?: string }).resource_id || {(g as { resource_id?: string }).resource_id ||
+16 -1
View File
@@ -94,7 +94,7 @@
"Add a new model to the system by providing the necessary information.": "通过提供必要信息向系统添加新模型。", "Add a new model to the system by providing the necessary information.": "通过提供必要信息向系统添加新模型。",
"Add a new user by providing necessary info.": "通过提供必要信息来添加新用户。", "Add a new user by providing necessary info.": "通过提供必要信息来添加新用户。",
"Add a new vendor to the system": "向系统添加新供应商", "Add a new vendor to the system": "向系统添加新供应商",
"Add agent": "添加 Agent", "Add agent": "添加智能体",
"Add an extra layer of security to your account": "为您的账户添加额外的安全层", "Add an extra layer of security to your account": "为您的账户添加额外的安全层",
"Add and submit": "添加后提交", "Add and submit": "添加后提交",
"Add Announcement": "添加公告", "Add Announcement": "添加公告",
@@ -4107,6 +4107,21 @@
"Waterfall": "瀑布", "Waterfall": "瀑布",
"Sub mode": "子模式", "Sub mode": "子模式",
"Agent": "智能体", "Agent": "智能体",
"Product role": "产品",
"Frontend role": "前端",
"Backend role": "后端",
"Reviewer role": "评审",
"Ops role": "运维",
"Builder role": "构建",
"Product Agnet": "产品智能体",
"Frontend Agnet": "前端智能体",
"Backend Agnet": "后端智能体",
"Reviewer Agnet": "评审智能体",
"Ops Agnet": "运维智能体",
"Git repository": "Git 仓库",
"SK skill pack": "SK 技能包",
"Cloud account": "云账号",
"Cloud resource": "云资源",
"Handoff": "交接", "Handoff": "交接",
"Event": "事件", "Event": "事件",
"Snapshot": "快照", "Snapshot": "快照",