From b9fe74b9e2e92b4dbfccd74a9525b51b7cdd59f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E9=98=BF=E6=B1=9F=28Relakkes?= =?UTF-8?q?=29?= Date: Thu, 8 Oct 2026 21:54:37 +0800 Subject: [PATCH] fix(desktop): label the custom provider preset in the active locale MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The custom preset showed the catalog's bare English "Custom" in every language and prefilled it as the config name. It now reads "Custom API" (自定义模型 API, etc.) on the chip and in the prefilled name. --- desktop/src/__tests__/generalSettings.test.tsx | 2 +- desktop/src/i18n/locales/en.ts | 1 + desktop/src/i18n/locales/jp.ts | 1 + desktop/src/i18n/locales/kr.ts | 1 + desktop/src/i18n/locales/zh-TW.ts | 1 + desktop/src/i18n/locales/zh.ts | 1 + .../src/pages/settings/ProviderSettings.test.tsx | 14 +++++++++++++- desktop/src/pages/settings/ProviderSettings.tsx | 12 ++++++++---- 8 files changed, 27 insertions(+), 6 deletions(-) diff --git a/desktop/src/__tests__/generalSettings.test.tsx b/desktop/src/__tests__/generalSettings.test.tsx index a4ea8c69..51d634e9 100644 --- a/desktop/src/__tests__/generalSettings.test.tsx +++ b/desktop/src/__tests__/generalSettings.test.tsx @@ -2392,7 +2392,7 @@ describe('Settings > Providers tab', () => { fireEvent.click(addButton) const dialog = screen.getByRole('dialog') - expect(within(dialog).getByLabelText(/Name/i)).toHaveValue('Custom') + expect(within(dialog).getByLabelText(/Name/i)).toHaveValue('Custom API') expect(within(dialog).getByRole('textbox', { name: /Base URL/i })).toBeEnabled() const baseUrlInfo = within(dialog).getByRole('button', { name: 'Base URL help' }) diff --git a/desktop/src/i18n/locales/en.ts b/desktop/src/i18n/locales/en.ts index b60d3481..5e0ef1fb 100644 --- a/desktop/src/i18n/locales/en.ts +++ b/desktop/src/i18n/locales/en.ts @@ -1442,6 +1442,7 @@ Row 9, all 8 cells: continuing from straight down, turning left through lower-le 'settings.providers.regionChina': 'China mainland', 'settings.providers.regionGlobal': 'Global', 'settings.providers.regionCustom': 'Custom', + 'settings.providers.customPreset': 'Custom API', 'settings.providers.apiKey': 'API Key', 'settings.providers.apiKeyKeep': 'API Key (leave blank to keep current)', 'settings.providers.showApiKey': 'Show API Key', diff --git a/desktop/src/i18n/locales/jp.ts b/desktop/src/i18n/locales/jp.ts index 01dfff53..91ea7aba 100644 --- a/desktop/src/i18n/locales/jp.ts +++ b/desktop/src/i18n/locales/jp.ts @@ -1443,6 +1443,7 @@ export const jp: Record = { 'settings.providers.regionChina': '中国本土', 'settings.providers.regionGlobal': 'グローバル', 'settings.providers.regionCustom': 'カスタム', + 'settings.providers.customPreset': 'カスタム API', 'settings.providers.apiKey': 'API キー', 'settings.providers.apiKeyKeep': 'API キー(空欄のままにすると現在の値を保持)', 'settings.providers.showApiKey': 'API キーを表示', diff --git a/desktop/src/i18n/locales/kr.ts b/desktop/src/i18n/locales/kr.ts index 1dcc4549..311b760c 100644 --- a/desktop/src/i18n/locales/kr.ts +++ b/desktop/src/i18n/locales/kr.ts @@ -1445,6 +1445,7 @@ export const kr: Record = { 'settings.providers.regionChina': '중국 본토', 'settings.providers.regionGlobal': '글로벌', 'settings.providers.regionCustom': '사용자 지정', + 'settings.providers.customPreset': '사용자 지정 API', 'settings.providers.apiKey': 'API 키', 'settings.providers.apiKeyKeep': 'API 키 (비워 두면 현재 값 유지)', 'settings.providers.showApiKey': 'API 키 표시', diff --git a/desktop/src/i18n/locales/zh-TW.ts b/desktop/src/i18n/locales/zh-TW.ts index 1bc92abd..dd258043 100644 --- a/desktop/src/i18n/locales/zh-TW.ts +++ b/desktop/src/i18n/locales/zh-TW.ts @@ -1442,6 +1442,7 @@ export const zh: Record = { 'settings.providers.regionChina': '中國大陸', 'settings.providers.regionGlobal': '海外', 'settings.providers.regionCustom': '自訂', + 'settings.providers.customPreset': '自訂模型 API', 'settings.providers.apiKey': 'API 金鑰', 'settings.providers.apiKeyKeep': 'API 金鑰(留空保持不變)', 'settings.providers.showApiKey': '顯示 API 金鑰', diff --git a/desktop/src/i18n/locales/zh.ts b/desktop/src/i18n/locales/zh.ts index ed9ad7ad..c120af9b 100644 --- a/desktop/src/i18n/locales/zh.ts +++ b/desktop/src/i18n/locales/zh.ts @@ -1441,6 +1441,7 @@ export const zh: Record = { 'settings.providers.regionChina': '中国大陆', 'settings.providers.regionGlobal': '海外', 'settings.providers.regionCustom': '自定义', + 'settings.providers.customPreset': '自定义模型 API', 'settings.providers.apiKey': 'API 密钥', 'settings.providers.apiKeyKeep': 'API 密钥(留空保持不变)', 'settings.providers.showApiKey': '显示 API 密钥', diff --git a/desktop/src/pages/settings/ProviderSettings.test.tsx b/desktop/src/pages/settings/ProviderSettings.test.tsx index 3cd01ea0..57529ca1 100644 --- a/desktop/src/pages/settings/ProviderSettings.test.tsx +++ b/desktop/src/pages/settings/ProviderSettings.test.tsx @@ -237,7 +237,19 @@ describe('retired sponsor providers', () => { expect(dialog.queryByRole('button', { name: provider.name })).not.toBeInTheDocument() } expect(dialog.getByRole('button', { name: 'Atlas Cloud' })).toBeInTheDocument() - expect(dialog.getByRole('button', { name: 'Custom' })).toBeInTheDocument() + expect(dialog.getByRole('button', { name: 'Custom API' })).toBeInTheDocument() + }) + + it('labels the custom preset in the active locale and prefills that label as the name', async () => { + useSettingsStore.setState({ locale: 'zh' }) + render() + await screen.findByTestId(`provider-${savedProviders[0]!.id}`) + + fireEvent.click(screen.getByRole('button', { name: /添加模型/ })) + const dialog = within(screen.getByRole('dialog')) + expect(dialog.queryByRole('button', { name: 'Custom' })).not.toBeInTheDocument() + fireEvent.click(dialog.getByRole('button', { name: '自定义模型 API' })) + expect(dialog.getByLabelText(/配置名称/)).toHaveValue('自定义模型 API') }) it.each(savedProviders)('edits and saves an existing $presetId provider without losing its connection', async (provider) => { diff --git a/desktop/src/pages/settings/ProviderSettings.tsx b/desktop/src/pages/settings/ProviderSettings.tsx index a327e9b7..90971504 100644 --- a/desktop/src/pages/settings/ProviderSettings.tsx +++ b/desktop/src/pages/settings/ProviderSettings.tsx @@ -1173,6 +1173,10 @@ function ProviderFormModal({ open, onClose, mode, provider, presets, browserMode const initialPreset = provider ? availablePresets.find((p) => p.id === provider.presetId) ?? fallbackPreset : selectablePresets[0] ?? fallbackPreset + // The custom preset's catalog name is a bare English "Custom"; show a localized + // label that says what it is for. + const presetLabel = (preset: ProviderPreset) => + preset.id === 'custom' ? t('settings.providers.customPreset') : preset.name const initialModels = stripModel1mMarkers(provider?.models ?? initialPreset.defaultModels) const initialImageGeneration = provider ? provider.imageGeneration @@ -1187,7 +1191,7 @@ function ProviderFormModal({ open, onClose, mode, provider, presets, browserMode ) const [selectedPreset, setSelectedPreset] = useState(initialPreset) - const [name, setName] = useState(provider?.name ?? initialPreset.name) + const [name, setName] = useState(provider?.name ?? presetLabel(initialPreset)) const [baseUrl, setBaseUrl] = useState(provider?.baseUrl ?? initialPreset.baseUrl) // A preset that decides the protocol per model owns this field: the picked value // is only the fallback for models no rule matches, so a record carrying a stale @@ -1349,7 +1353,7 @@ function ProviderFormModal({ open, onClose, mode, provider, presets, browserMode settingsJsonUserEditedRef.current = false setSelectedPreset(preset) setCompatibility(compatibilityForm()) - setName(preset.name) + setName(presetLabel(preset)) setBaseUrl(preset.baseUrl) setImageGeneration({ enabled: Boolean(preset.defaultImageGeneration), @@ -1687,14 +1691,14 @@ function ProviderFormModal({ open, onClose, mode, provider, presets, browserMode const renderPresetButton = (preset: ProviderPreset) => ( handlePresetChange(preset)} > {preset.id === 'aruhub' && } - {preset.name} + {presetLabel(preset)} {preset.id === 'aruhub' && } {preset.isNew && (