i18n: complete internationalization for provider and usage query panels

- Add 45+ new translation keys for usage query and usage script features
- Fix duplicate provider object in translation files that caused missing translations
- Remove all hardcoded Chinese text and defaultValue fallbacks from components
- Add proper translations for:
  * Usage footer (query status, plan usage display)
  * Usage script modal (script editor, validation, test controls)
  * Provider forms (basic fields, endpoints, model selectors)
  * Provider dialogs (add/edit hints and titles)

Modified 16 files:
- 2 translation files (zh.json, en.json)
- 14 component files (removed defaultValue, added t() calls)

All UI text now properly supports Chinese/English switching.
This commit is contained in:
Jason
2025-10-19 11:55:46 +08:00
parent bae6a1cf55
commit eb6948a562
16 changed files with 176 additions and 125 deletions

View File

@@ -25,14 +25,12 @@ export function BasicFormFields({ form }: BasicFormFieldsProps) {
render={({ field }) => (
<FormItem>
<FormLabel>
{t("provider.name", { defaultValue: "供应商名称" })}
{t("provider.name")}
</FormLabel>
<FormControl>
<Input
{...field}
placeholder={t("provider.namePlaceholder", {
defaultValue: "例如Claude 官方",
})}
placeholder={t("provider.namePlaceholder")}
/>
</FormControl>
<FormMessage />
@@ -46,7 +44,7 @@ export function BasicFormFields({ form }: BasicFormFieldsProps) {
render={({ field }) => (
<FormItem>
<FormLabel>
{t("provider.websiteUrl", { defaultValue: "官网链接" })}
{t("provider.websiteUrl")}
</FormLabel>
<FormControl>
<Input {...field} placeholder="https://" />

View File

@@ -137,15 +137,11 @@ export function ClaudeFormFields({
{shouldShowSpeedTest && (
<EndpointField
id="baseUrl"
label={t("providerForm.apiEndpoint", { defaultValue: "API 端点" })}
label={t("providerForm.apiEndpoint")}
value={baseUrl}
onChange={onBaseUrlChange}
placeholder={t("providerForm.apiEndpointPlaceholder", {
defaultValue: "https://api.example.com",
})}
hint={t("providerForm.apiHint", {
defaultValue: "API 端点地址用于连接服务器",
})}
placeholder={t("providerForm.apiEndpointPlaceholder")}
hint={t("providerForm.apiHint")}
onManageClick={() => onEndpointModalToggle(true)}
/>
)}

View File

@@ -68,15 +68,11 @@ export function CodexFormFields({
{shouldShowSpeedTest && (
<EndpointField
id="codexBaseUrl"
label={t("codexConfig.apiUrlLabel", { defaultValue: "API 端点" })}
label={t("codexConfig.apiUrlLabel")}
value={codexBaseUrl}
onChange={onBaseUrlChange}
placeholder={t("providerForm.codexApiEndpointPlaceholder", {
defaultValue: "https://api.example.com/v1",
})}
hint={t("providerForm.codexApiHint", {
defaultValue: "Codex API 端点地址",
})}
placeholder={t("providerForm.codexApiEndpointPlaceholder")}
hint={t("providerForm.codexApiHint")}
onManageClick={() => onEndpointModalToggle(true)}
/>
)}

View File

@@ -51,7 +51,7 @@ export function CommonConfigEditor({
<div className="space-y-2">
<div className="flex items-center justify-between">
<Label htmlFor="settingsConfig">
{t("provider.configJson", { defaultValue: "配置 JSON" })}
{t("provider.configJson")}
</Label>
<div className="flex items-center gap-2">
<label className="inline-flex items-center gap-2 text-sm text-muted-foreground cursor-pointer">

View File

@@ -554,7 +554,7 @@ export function ProviderForm({
{showButtons && (
<div className="flex justify-end gap-2">
<Button variant="outline" type="button" onClick={onCancel}>
{t("common.cancel", { defaultValue: "取消" })}
{t("common.cancel")}
</Button>
<Button type="submit">{submitLabel}</Button>
</div>

View File

@@ -28,7 +28,7 @@ export function ProviderPresetSelector({
return (
<div className="space-y-3">
<FormLabel>
{t("providerPreset.label", { defaultValue: "预设供应商" })}
{t("providerPreset.label")}
</FormLabel>
<div className="flex flex-wrap gap-2">
{/* 自定义按钮 */}
@@ -41,7 +41,7 @@ export function ProviderPresetSelector({
: "bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-gray-700"
}`}
>
{t("providerPreset.custom", { defaultValue: "自定义配置" })}
{t("providerPreset.custom")}
</button>
{/* 预设按钮 */}