From a65632e34274134fa5fb8e002527970d91f7ddf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B9=E9=9B=AA?= <2b@yorha.xyz> Date: Thu, 11 Jun 2026 02:20:53 +0900 Subject: [PATCH] feat(ui): i18n for agent form and card --- .../src/components/agents/add_agent_form.tsx | 249 +++++++++++------- .../src/components/agents/agent_card.tsx | 18 +- ui/litellm-dashboard/src/locales/en.json | 92 +++++++ ui/litellm-dashboard/src/locales/zh-CN.json | 92 +++++++ 4 files changed, 351 insertions(+), 100 deletions(-) diff --git a/ui/litellm-dashboard/src/components/agents/add_agent_form.tsx b/ui/litellm-dashboard/src/components/agents/add_agent_form.tsx index 72df808b0a3..fb4bfd89107 100644 --- a/ui/litellm-dashboard/src/components/agents/add_agent_form.tsx +++ b/ui/litellm-dashboard/src/components/agents/add_agent_form.tsx @@ -1,5 +1,6 @@ import React, { useState, useEffect } from "react"; import { Modal, Form, Select, Input, Steps, Radio, Tag, Divider, Switch, InputNumber, Collapse } from "antd"; +import { useTranslation } from "react-i18next"; import MessageManager from "@/components/molecules/message_manager"; import { Button } from "@tremor/react"; import { CheckCircleFilled, KeyOutlined, RobotOutlined, AppstoreOutlined, InfoCircleOutlined } from "@ant-design/icons"; @@ -40,6 +41,7 @@ interface AddAgentFormProps { } const AddAgentForm: React.FC = ({ visible, onClose, accessToken, onSuccess, teams }) => { + const { t } = useTranslation(); const { userId, userRole } = useAuthorized(); const [form] = Form.useForm(); const [currentStep, setCurrentStep] = useState(0); @@ -244,7 +246,7 @@ const AddAgentForm: React.FC = ({ visible, onClose, accessTok const handleCreateAgent = async () => { if (!accessToken) { - MessageManager.error("No access token available"); + MessageManager.error(t("agentsPage.addAgentForm.noAccessToken")); return; } @@ -254,7 +256,7 @@ const AddAgentForm: React.FC = ({ visible, onClose, accessTok const values = { ...form.getFieldsValue(true) }; const agentData = buildAgentData(values); if (!agentData) { - MessageManager.error("Failed to build agent data"); + MessageManager.error(t("agentsPage.addAgentForm.failedToBuildAgentData")); setIsSubmitting(false); return; } @@ -330,7 +332,7 @@ const AddAgentForm: React.FC = ({ visible, onClose, accessTok setCreatedKeyValue(keyResponse.key || null); } else if (keyAssignOption === "existing_key") { if (!selectedExistingKey) { - MessageManager.error("Please select an existing key to assign"); + MessageManager.error(t("agentsPage.addAgentForm.pleaseSelectExistingKey")); setIsSubmitting(false); return; } @@ -347,7 +349,11 @@ const AddAgentForm: React.FC = ({ visible, onClose, accessTok } catch (error) { console.error("Error creating agent:", error); const errorMessage = error instanceof Error ? error.message : String(error); - MessageManager.error(errorMessage ? `Failed to create agent: ${errorMessage}` : "Failed to create agent"); + MessageManager.error( + errorMessage + ? t("agentsPage.addAgentForm.failedToCreateAgent", { error: errorMessage }) + : t("agentsPage.addAgentForm.failedToCreateAgentGeneric"), + ); } finally { setIsSubmitting(false); } @@ -374,20 +380,23 @@ const AddAgentForm: React.FC = ({ visible, onClose, accessTok const renderEntitlementsStep = () => (
-

- Configure which models, agents, and MCP tools this agent is allowed to use. Leave fields empty to allow all - (subject to key/team permissions). -

+

{t("agentsPage.addAgentForm.entitlementsIntro")}

Allowed Models} + label={ + {t("agentsPage.addAgentForm.allowedModelsLabel")} + } name="entitlement_models" - tooltip="Restrict which models this agent can call. Leave empty to allow all." + tooltip={t("agentsPage.addAgentForm.allowedModelsTooltip")} > @@ -424,9 +439,9 @@ const AddAgentForm: React.FC = ({ visible, onClose, accessTok - Allowed MCP Servers{" "} + {t("agentsPage.addAgentForm.allowedMcpServersLabel")}{" "} @@ -440,7 +455,7 @@ const AddAgentForm: React.FC = ({ visible, onClose, accessTok } value={form.getFieldValue("allowed_mcp_servers_and_groups") || { servers: [], accessGroups: [] }} accessToken={accessToken ?? ""} - placeholder="Select MCP servers or access groups (optional)" + placeholder={t("agentsPage.addAgentForm.mcpServerSelectorPlaceholder")} />