From 2f069a0a5fb14af52c58ab02e3c6785fd9e4cc13 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 05:16:21 +0900 Subject: [PATCH] feat(ui): i18n for tag management --- .../components/tag_management/TagSelector.tsx | 4 +- .../components/tag_management/TagTable.tsx | 34 ++++--- .../components/CreateTagModal.tsx | 59 +++++++----- .../src/components/tag_management/index.tsx | 50 ++++++---- .../components/tag_management/tag_info.tsx | 95 +++++++++++-------- ui/litellm-dashboard/src/locales/en.json | 77 +++++++++++++++ ui/litellm-dashboard/src/locales/zh-CN.json | 77 +++++++++++++++ 7 files changed, 293 insertions(+), 103 deletions(-) diff --git a/ui/litellm-dashboard/src/components/tag_management/TagSelector.tsx b/ui/litellm-dashboard/src/components/tag_management/TagSelector.tsx index 736c8dc61cd..f597de3eb3b 100644 --- a/ui/litellm-dashboard/src/components/tag_management/TagSelector.tsx +++ b/ui/litellm-dashboard/src/components/tag_management/TagSelector.tsx @@ -1,5 +1,6 @@ import React, { useEffect, useState } from "react"; import { Select } from "antd"; +import { useTranslation } from "react-i18next"; import { Tag } from "./types"; import { tagListCall } from "../networking"; @@ -11,6 +12,7 @@ interface TagSelectorProps { } const TagSelector: React.FC = ({ onChange, value, className, accessToken }) => { + const { t } = useTranslation(); const [tags, setTags] = useState([]); const [loading, setLoading] = useState(false); @@ -35,7 +37,7 @@ const TagSelector: React.FC = ({ onChange, value, className, a - + - Allowed Models - + {t("tagManagement.tagInfo.allowedModelsLabel")} + } name="models" > - + {userModels.map((modelId) => ( {getModelDisplayName(modelId)} @@ -170,14 +178,14 @@ const TagInfoView: React.FC = ({ tagId, onClose, accessToken, - Budget & Rate Limits + {t("tagManagement.tagInfo.budgetRateLimits")} - Max Budget (USD){" "} - + {t("tagManagement.tagInfo.maxBudgetLabel")}{" "} + @@ -190,8 +198,8 @@ const TagInfoView: React.FC = ({ tagId, onClose, accessToken, - Reset Budget{" "} - + {t("tagManagement.tagInfo.resetBudgetLabel")}{" "} + @@ -203,45 +211,48 @@ const TagInfoView: React.FC = ({ tagId, onClose, accessToken,

- TPM/RPM limits for tags are not currently supported. If you need this feature, please{" "} - - create a GitHub issue - - . + + ), + }} + />

- - + +
) : (
- Tag Details + {t("tagManagement.tagInfo.tagDetails")}
- Name + {t("common.name")} {tagDetails.name}
- Description + {t("common.description")} {tagDetails.description || "-"}
- Allowed Models + {t("tagManagement.tagInfo.allowedModelsLabel")}
{!tagDetails.models || tagDetails.models.length === 0 ? ( - All Models + {t("tagManagement.tagInfo.allModels")} ) : ( tagDetails.models.map((modelId) => ( @@ -252,11 +263,11 @@ const TagInfoView: React.FC = ({ tagId, onClose, accessToken,
- Created + {t("tagManagement.tagInfo.created")} {tagDetails.created_at ? new Date(tagDetails.created_at).toLocaleString() : "-"}
- Last Updated + {t("tagManagement.tagInfo.lastUpdated")} {tagDetails.updated_at ? new Date(tagDetails.updated_at).toLocaleString() : "-"}
@@ -264,32 +275,32 @@ const TagInfoView: React.FC = ({ tagId, onClose, accessToken, {tagDetails.litellm_budget_table && ( - Budget & Rate Limits + {t("tagManagement.tagInfo.budgetRateLimits")}
{tagDetails.litellm_budget_table.max_budget !== undefined && tagDetails.litellm_budget_table.max_budget !== null && (
- Max Budget + {t("tagManagement.tagInfo.maxBudget")} ${tagDetails.litellm_budget_table.max_budget}
)} {tagDetails.litellm_budget_table.budget_duration && (
- Budget Duration + {t("tagManagement.tagInfo.budgetDuration")} {tagDetails.litellm_budget_table.budget_duration}
)} {tagDetails.litellm_budget_table.tpm_limit !== undefined && tagDetails.litellm_budget_table.tpm_limit !== null && (
- TPM Limit + {t("tagManagement.tagInfo.tpmLimit")} {tagDetails.litellm_budget_table.tpm_limit.toLocaleString()}
)} {tagDetails.litellm_budget_table.rpm_limit !== undefined && tagDetails.litellm_budget_table.rpm_limit !== null && (
- RPM Limit + {t("tagManagement.tagInfo.rpmLimit")} {tagDetails.litellm_budget_table.rpm_limit.toLocaleString()}
)} diff --git a/ui/litellm-dashboard/src/locales/en.json b/ui/litellm-dashboard/src/locales/en.json index 01c316faa9d..983316689cd 100644 --- a/ui/litellm-dashboard/src/locales/en.json +++ b/ui/litellm-dashboard/src/locales/en.json @@ -7385,5 +7385,82 @@ "description": "Help us improve LiteLLM! Share your experience in 5 quick questions.", "buttonText": "Share feedback" } + }, + "tagManagement": { + "tagSelector": { + "placeholder": "Select or create tags" + }, + "tagTable": { + "colTagName": "Tag Name", + "colAllowedModels": "Allowed Models", + "colCreated": "Created", + "allModels": "All Models", + "dynamicTagViewDisabled": "You cannot view the information of a dynamically generated spend tag", + "dynamicTagEditDisabled": "Dynamically generated spend tags cannot be edited", + "dynamicTagDeleteDisabled": "Dynamically generated spend tags cannot be deleted", + "editTagTooltip": "Edit tag", + "editTagDisabledAriaLabel": "Edit tag (disabled)", + "deleteTagTooltip": "Delete tag", + "deleteTagDisabledAriaLabel": "Delete tag (disabled)", + "noTagsFound": "No tags found" + }, + "createTagModal": { + "title": "Create New Tag", + "tagNameLabel": "Tag Name", + "tagNameRequired": "Please input a tag name", + "allowedModelsLabel": "Allowed Models", + "allowedModelsTooltip": "Select which models are allowed to process requests from this tag", + "selectModelsPlaceholder": "Select Models", + "budgetRateLimitsOptional": "Budget & Rate Limits (Optional)", + "maxBudgetLabel": "Max Budget (USD)", + "maxBudgetTooltip": "Maximum amount in USD this tag can spend. When reached, requests with this tag will be blocked", + "resetBudgetLabel": "Reset Budget", + "resetBudgetTooltip": "How often the budget should reset. For example, setting 'daily' will reset the budget every 24 hours", + "tpmRpmNotSupported": "TPM/RPM limits for tags are not currently supported. If you need this feature, please create a GitHub issue.", + "createTagButton": "+ Create New Tag" + }, + "index": { + "pageTitle": "Tag Management", + "lastRefreshed": "Last Refreshed: {{time}}", + "clickTagNameHint": "Click on a tag name to view and edit its details.", + "tagRoutingDescription": "You can use tags to restrict the usage of certain LLMs based on tags passed in the request. Read more about tag routing here.", + "createNewTagButton": "+ Create New Tag", + "deleteTagTitle": "Delete Tag", + "deleteTagConfirm": "Are you sure you want to delete this tag?", + "errorFetchingTags": "Error fetching tags: {{error}}", + "tagCreatedSuccess": "Tag created successfully", + "errorCreatingTag": "Error creating tag: {{error}}", + "tagDeletedSuccess": "Tag deleted successfully", + "errorDeletingTag": "Error deleting tag: {{error}}", + "errorFetchingModels": "Error fetching models: {{error}}" + }, + "tagInfo": { + "backToTags": "← Back to Tags", + "tagNameLabel": "Tag Name:", + "noDescription": "No description", + "editTagButton": "Edit Tag", + "tagNameRequired": "Please input a tag name", + "allowedModelsLabel": "Allowed Models", + "allowedModelsTooltip": "Select which models are allowed to process this type of data", + "selectModelsPlaceholder": "Select Models", + "budgetRateLimits": "Budget & Rate Limits", + "maxBudgetLabel": "Max Budget (USD)", + "maxBudgetTooltip": "Maximum amount in USD this tag can spend", + "resetBudgetLabel": "Reset Budget", + "resetBudgetTooltip": "How often the budget should reset", + "tpmRpmNotSupported": "TPM/RPM limits for tags are not currently supported. If you need this feature, please create a GitHub issue.", + "saveChanges": "Save Changes", + "tagDetails": "Tag Details", + "allModels": "All Models", + "created": "Created", + "lastUpdated": "Last Updated", + "maxBudget": "Max Budget", + "budgetDuration": "Budget Duration", + "tpmLimit": "TPM Limit", + "rpmLimit": "RPM Limit", + "errorFetchingTagDetails": "Error fetching tag details: {{error}}", + "tagUpdatedSuccess": "Tag updated successfully", + "errorUpdatingTag": "Error updating tag: {{error}}" + } } } diff --git a/ui/litellm-dashboard/src/locales/zh-CN.json b/ui/litellm-dashboard/src/locales/zh-CN.json index bc458fe6bb1..04dddc9918b 100644 --- a/ui/litellm-dashboard/src/locales/zh-CN.json +++ b/ui/litellm-dashboard/src/locales/zh-CN.json @@ -7385,5 +7385,82 @@ "description": "帮助我们改进 LiteLLM!通过 5 个简短问题分享您的使用体验。", "buttonText": "分享反馈" } + }, + "tagManagement": { + "tagSelector": { + "placeholder": "选择或创建标签" + }, + "tagTable": { + "colTagName": "标签名称", + "colAllowedModels": "允许的模型", + "colCreated": "创建时间", + "allModels": "所有模型", + "dynamicTagViewDisabled": "您无法查看动态生成的花费标签的信息", + "dynamicTagEditDisabled": "动态生成的花费标签无法编辑", + "dynamicTagDeleteDisabled": "动态生成的花费标签无法删除", + "editTagTooltip": "编辑标签", + "editTagDisabledAriaLabel": "编辑标签(已禁用)", + "deleteTagTooltip": "删除标签", + "deleteTagDisabledAriaLabel": "删除标签(已禁用)", + "noTagsFound": "未找到标签" + }, + "createTagModal": { + "title": "创建新标签", + "tagNameLabel": "标签名称", + "tagNameRequired": "请输入标签名称", + "allowedModelsLabel": "允许的模型", + "allowedModelsTooltip": "选择允许处理此标签请求的模型", + "selectModelsPlaceholder": "选择模型", + "budgetRateLimitsOptional": "预算与速率限制(可选)", + "maxBudgetLabel": "最大预算(美元)", + "maxBudgetTooltip": "此标签可花费的最大金额(美元)。达到上限后,携带此标签的请求将被拒绝", + "resetBudgetLabel": "重置预算", + "resetBudgetTooltip": "预算重置频率。例如,设置为「每天」将每 24 小时重置一次预算", + "tpmRpmNotSupported": "标签的 TPM/RPM 限制暂不支持。如需此功能,请 创建 GitHub Issue。", + "createTagButton": "+ 创建新标签" + }, + "index": { + "pageTitle": "标签管理", + "lastRefreshed": "最后刷新:{{time}}", + "clickTagNameHint": "点击标签名称可查看并编辑其详情。", + "tagRoutingDescription": "您可以使用标签,根据请求中携带的标签来限制特定 LLM 的使用。了解更多标签路由内容,请查阅 文档。", + "createNewTagButton": "+ 创建新标签", + "deleteTagTitle": "删除标签", + "deleteTagConfirm": "确定要删除此标签吗?", + "errorFetchingTags": "获取标签失败:{{error}}", + "tagCreatedSuccess": "标签创建成功", + "errorCreatingTag": "创建标签失败:{{error}}", + "tagDeletedSuccess": "标签删除成功", + "errorDeletingTag": "删除标签失败:{{error}}", + "errorFetchingModels": "获取模型失败:{{error}}" + }, + "tagInfo": { + "backToTags": "← 返回标签列表", + "tagNameLabel": "标签名称:", + "noDescription": "暂无描述", + "editTagButton": "编辑标签", + "tagNameRequired": "请输入标签名称", + "allowedModelsLabel": "允许的模型", + "allowedModelsTooltip": "选择允许处理此类数据的模型", + "selectModelsPlaceholder": "选择模型", + "budgetRateLimits": "预算与速率限制", + "maxBudgetLabel": "最大预算(美元)", + "maxBudgetTooltip": "此标签可花费的最大金额(美元)", + "resetBudgetLabel": "重置预算", + "resetBudgetTooltip": "预算重置频率", + "tpmRpmNotSupported": "标签的 TPM/RPM 限制暂不支持。如需此功能,请 创建 GitHub Issue。", + "saveChanges": "保存更改", + "tagDetails": "标签详情", + "allModels": "所有模型", + "created": "创建时间", + "lastUpdated": "最后更新", + "maxBudget": "最大预算", + "budgetDuration": "预算周期", + "tpmLimit": "TPM 限制", + "rpmLimit": "RPM 限制", + "errorFetchingTagDetails": "获取标签详情失败:{{error}}", + "tagUpdatedSuccess": "标签更新成功", + "errorUpdatingTag": "更新标签失败:{{error}}" + } } }