From b69ca5f027ed049f5f7222ba36e79b11b7d3c754 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 07:29:47 +0900 Subject: [PATCH] feat(ui): i18n for budget windows editor --- .../key_team_helpers/BudgetWindowsEditor.tsx | 41 ++++++++++++++----- ui/litellm-dashboard/src/locales/en.json | 14 +++++++ ui/litellm-dashboard/src/locales/zh-CN.json | 14 +++++++ 3 files changed, 59 insertions(+), 10 deletions(-) diff --git a/ui/litellm-dashboard/src/components/key_team_helpers/BudgetWindowsEditor.tsx b/ui/litellm-dashboard/src/components/key_team_helpers/BudgetWindowsEditor.tsx index 0c90674a479..38b796cea79 100644 --- a/ui/litellm-dashboard/src/components/key_team_helpers/BudgetWindowsEditor.tsx +++ b/ui/litellm-dashboard/src/components/key_team_helpers/BudgetWindowsEditor.tsx @@ -1,16 +1,34 @@ import { Button, InputNumber, Select } from "antd"; -import React from "react"; +import React, { useMemo } from "react"; +import { useTranslation } from "react-i18next"; +import type { TFunction } from "i18next"; export interface BudgetWindowEntry { budget_duration: string; max_budget: number | null; } -export const BUDGET_WINDOW_OPTIONS = [ - { value: "1h", label: "Hourly", resetHint: "Resets every hour" }, - { value: "24h", label: "Daily", resetHint: "Resets daily at midnight UTC" }, - { value: "7d", label: "Weekly", resetHint: "Resets every Sunday at midnight UTC" }, - { value: "30d", label: "Monthly", resetHint: "Resets on the 1st of every month at midnight UTC" }, +const getBudgetWindowOptions = (t: TFunction) => [ + { + value: "1h", + label: t("keyTeamHelpers.budgetWindowsEditor.hourly"), + resetHint: t("keyTeamHelpers.budgetWindowsEditor.resetsEveryHour"), + }, + { + value: "24h", + label: t("keyTeamHelpers.budgetWindowsEditor.daily"), + resetHint: t("keyTeamHelpers.budgetWindowsEditor.resetsDailyMidnight"), + }, + { + value: "7d", + label: t("keyTeamHelpers.budgetWindowsEditor.weekly"), + resetHint: t("keyTeamHelpers.budgetWindowsEditor.resetsWeeklySunday"), + }, + { + value: "30d", + label: t("keyTeamHelpers.budgetWindowsEditor.monthly"), + resetHint: t("keyTeamHelpers.budgetWindowsEditor.resetsMonthly"), + }, ]; interface BudgetWindowsEditorProps { @@ -19,6 +37,9 @@ interface BudgetWindowsEditorProps { } export function BudgetWindowsEditor({ value, onChange }: BudgetWindowsEditorProps) { + const { t } = useTranslation(); + const budgetWindowOptions = useMemo(() => getBudgetWindowOptions(t), [t]); + const addWindow = () => { onChange([...value, { budget_duration: "24h", max_budget: null }]); }; @@ -35,7 +56,7 @@ export function BudgetWindowsEditor({ value, onChange }: BudgetWindowsEditorProp return (