diff --git a/components/model-config-dialog.tsx b/components/model-config-dialog.tsx index e94dcdb..89f17a2 100644 --- a/components/model-config-dialog.tsx +++ b/components/model-config-dialog.tsx @@ -52,6 +52,7 @@ import { } from "@/components/ui/select" import { useDictionary } from "@/hooks/use-dictionary" import type { UseModelConfigReturn } from "@/hooks/use-model-config" +import { formatMessage } from "@/lib/i18n/utils" import type { ProviderConfig, ProviderName } from "@/lib/types/model-config" import { PROVIDER_INFO, SUGGESTED_MODELS } from "@/lib/types/model-config" import { cn } from "@/lib/utils" @@ -107,10 +108,12 @@ function ValidationButton({ status, onClick, disabled, + dict, }: { status: ValidationStatus onClick: () => void disabled: boolean + dict: ReturnType }) { return ( ) @@ -406,7 +409,7 @@ export function ModelConfigDialog({
- Providers + {dict.modelConfig.providers}
@@ -418,7 +421,7 @@ export function ModelConfigDialog({

- Add a provider to get started + {dict.modelConfig.addProviderHint}

) : ( @@ -484,7 +487,11 @@ export function ModelConfigDialog({ > - + {availableProviders.map((p) => ( @@ -552,15 +559,27 @@ export function ModelConfigDialog({

{selectedProvider.models .length === 0 - ? "No models configured" - : `${selectedProvider.models.length} model${selectedProvider.models.length > 1 ? "s" : ""} configured`} + ? dict.modelConfig + .noModelsConfigured + : formatMessage( + dict.modelConfig + .modelsConfiguredCount, + { + count: selectedProvider + .models + .length, + }, + )}

{selectedProvider.validated && (
- Verified + { + dict.modelConfig + .verified + }
)} @@ -570,7 +589,12 @@ export function ModelConfigDialog({
- Configuration + + { + dict.modelConfig + .configuration + } +
@@ -581,7 +605,10 @@ export function ModelConfigDialog({ className="text-xs font-medium flex items-center gap-1.5" > - Display Name + { + dict.modelConfig + .displayName + } - AWS Access Key - ID + { + dict + .modelConfig + .awsAccessKeyId + } - AWS Secret - Access Key + { + dict + .modelConfig + .awsSecretAccessKey + }
@@ -1395,11 +1494,10 @@ export function ModelConfigDialog({

- Configure AI Providers + {dict.modelConfig.configureProviders}

- Select a provider from the list or add a new - one to configure API keys and models + {dict.modelConfig.selectProviderHint}

)} @@ -1410,7 +1508,7 @@ export function ModelConfigDialog({

- API keys are stored locally in your browser + {dict.modelConfig.apiKeyStored}

@@ -1429,19 +1527,16 @@ export function ModelConfigDialog({ - Delete Provider + {dict.modelConfig.deleteProvider} - Are you sure you want to delete{" "} - - {selectedProvider + {formatMessage(dict.modelConfig.deleteConfirmDesc, { + name: selectedProvider ? selectedProvider.name || PROVIDER_INFO[selectedProvider.provider] .label - : "this provider"} - - ? This will remove all configured models and cannot - be undone. + : "this provider", + })} {selectedProvider && @@ -1451,11 +1546,16 @@ export function ModelConfigDialog({ htmlFor="delete-confirm" className="text-sm text-muted-foreground" > - Type " - {selectedProvider.name || - PROVIDER_INFO[selectedProvider.provider] - .label} - " to confirm + {formatMessage( + dict.modelConfig.typeToConfirm, + { + name: + selectedProvider.name || + PROVIDER_INFO[ + selectedProvider.provider + ].label, + }, + )} setDeleteConfirmText(e.target.value) } - placeholder="Type provider name..." + placeholder={ + dict.modelConfig.typeProviderName + } className="h-9" /> )} - Cancel + + {dict.modelConfig.cancel} + - Delete + {dict.modelConfig.delete} diff --git a/components/model-selector.tsx b/components/model-selector.tsx index 37baa4c..cefab04 100644 --- a/components/model-selector.tsx +++ b/components/model-selector.tsx @@ -16,6 +16,7 @@ import { ModelSelectorTrigger, } from "@/components/ai-elements/model-selector" import { ButtonWithTooltip } from "@/components/button-with-tooltip" +import { useDictionary } from "@/hooks/use-dictionary" import type { FlattenedModel } from "@/lib/types/model-config" import { cn } from "@/lib/utils" @@ -67,6 +68,7 @@ export function ModelSelector({ onConfigure, disabled = false, }: ModelSelectorProps) { + const dict = useDictionary() const [open, setOpen] = useState(false) // Only show validated models in the selector const validatedModels = useMemo( @@ -96,8 +98,8 @@ export function ModelSelector({ } const tooltipContent = selectedModel - ? `${selectedModel.modelId} (click to change)` - : "Using server default model (click to change)" + ? `${selectedModel.modelId} ${dict.modelConfig.clickToChange}` + : `${dict.modelConfig.usingServerDefault} ${dict.modelConfig.clickToChange}` return ( @@ -111,22 +113,26 @@ export function ModelSelector({ > - {selectedModel ? selectedModel.modelId : "Default"} + {selectedModel + ? selectedModel.modelId + : dict.modelConfig.default} - - + + {validatedModels.length === 0 && models.length > 0 - ? "No verified models. Test your models first." - : "No models found."} + ? dict.modelConfig.noVerifiedModels + : dict.modelConfig.noModelsFound} {/* Server Default Option */} - + - Server Default + {dict.modelConfig.serverDefault} @@ -201,13 +207,13 @@ export function ModelSelector({ > - Configure Models... + {dict.modelConfig.configureModels} {/* Info text */}
- Only verified models are shown + {dict.modelConfig.onlyVerifiedShown}
diff --git a/lib/i18n/dictionaries/en.json b/lib/i18n/dictionaries/en.json index 5fc1ac3..2d6b1fe 100644 --- a/lib/i18n/dictionaries/en.json +++ b/lib/i18n/dictionaries/en.json @@ -202,6 +202,47 @@ "apiKeyStored": "API keys are stored locally in your browser", "test": "Test", "validationError": "Validation failed", - "addModelFirst": "Add at least one model to validate" + "addModelFirst": "Add at least one model to validate", + "providers": "Providers", + "addProviderHint": "Add a provider to get started", + "verified": "Verified", + "configuration": "Configuration", + "displayName": "Display Name", + "awsAccessKeyId": "AWS Access Key ID", + "awsSecretAccessKey": "AWS Secret Access Key", + "awsRegion": "AWS Region", + "selectRegion": "Select region", + "apiKey": "API Key", + "enterApiKey": "Enter your API key", + "enterSecretKey": "Enter your secret access key", + "baseUrl": "Base URL", + "optional": "(optional)", + "customEndpoint": "Custom endpoint URL", + "models": "Models", + "customModelId": "Custom model ID...", + "allAdded": "All added", + "suggested": "Suggested", + "noModelsConfigured": "No models configured", + "modelIdEmpty": "Model ID cannot be empty", + "modelIdExists": "This model ID already exists", + "configureProviders": "Configure AI Providers", + "selectProviderHint": "Select a provider from the list or add a new one to configure API keys and models", + "deleteConfirmDesc": "Are you sure you want to delete {name}? This will remove all configured models and cannot be undone.", + "typeToConfirm": "Type \"{name}\" to confirm", + "typeProviderName": "Type provider name...", + "modelsConfiguredCount": "{count} model(s) configured", + "validationFailedCount": "{count} model(s) failed validation", + "cancel": "Cancel", + "delete": "Delete", + "clickToChange": "(click to change)", + "usingServerDefault": "Using server default model", + "selectModel": "Select Model", + "searchModels": "Search models...", + "noVerifiedModels": "No verified models. Test your models first.", + "noModelsFound": "No models found.", + "default": "Default", + "serverDefault": "Server Default", + "configureModels": "Configure Models...", + "onlyVerifiedShown": "Only verified models are shown" } } diff --git a/lib/i18n/dictionaries/ja.json b/lib/i18n/dictionaries/ja.json index d622337..6b86e4e 100644 --- a/lib/i18n/dictionaries/ja.json +++ b/lib/i18n/dictionaries/ja.json @@ -202,6 +202,47 @@ "apiKeyStored": "APIキーはブラウザにローカル保存されます", "test": "テスト", "validationError": "検証に失敗しました", - "addModelFirst": "検証するには少なくとも1つのモデルを追加してください" + "addModelFirst": "検証するには少なくとも1つのモデルを追加してください", + "providers": "プロバイダー", + "addProviderHint": "プロバイダーを追加して開始", + "verified": "検証済み", + "configuration": "設定", + "displayName": "表示名", + "awsAccessKeyId": "AWS アクセスキー ID", + "awsSecretAccessKey": "AWS シークレットアクセスキー", + "awsRegion": "AWS リージョン", + "selectRegion": "リージョンを選択", + "apiKey": "API キー", + "enterApiKey": "API キーを入力", + "enterSecretKey": "シークレットアクセスキーを入力", + "baseUrl": "ベース URL", + "optional": "(オプション)", + "customEndpoint": "カスタムエンドポイント URL", + "models": "モデル", + "customModelId": "カスタムモデル ID...", + "allAdded": "すべて追加済み", + "suggested": "おすすめ", + "noModelsConfigured": "モデルが設定されていません", + "modelIdEmpty": "モデル ID は空にできません", + "modelIdExists": "このモデル ID は既に存在します", + "configureProviders": "AI プロバイダーを設定", + "selectProviderHint": "リストからプロバイダーを選択するか、新規追加して API キーとモデルを設定", + "deleteConfirmDesc": "{name} を削除してもよろしいですか?設定されたすべてのモデルが削除され、元に戻せません。", + "typeToConfirm": "確認のため「{name}」と入力", + "typeProviderName": "プロバイダー名を入力...", + "modelsConfiguredCount": "{count} 個のモデルを設定済み", + "validationFailedCount": "{count} 個のモデルの検証に失敗", + "cancel": "キャンセル", + "delete": "削除", + "clickToChange": "(クリックして変更)", + "usingServerDefault": "サーバーデフォルトモデルを使用中", + "selectModel": "モデルを選択", + "searchModels": "モデルを検索...", + "noVerifiedModels": "検証済みのモデルがありません。先にモデルをテストしてください。", + "noModelsFound": "モデルが見つかりません。", + "default": "デフォルト", + "serverDefault": "サーバーデフォルト", + "configureModels": "モデルを設定...", + "onlyVerifiedShown": "検証済みのモデルのみ表示" } } diff --git a/lib/i18n/dictionaries/zh.json b/lib/i18n/dictionaries/zh.json index eec9836..7b3413c 100644 --- a/lib/i18n/dictionaries/zh.json +++ b/lib/i18n/dictionaries/zh.json @@ -202,6 +202,47 @@ "apiKeyStored": "API 密钥存储在您的浏览器本地", "test": "测试", "validationError": "验证失败", - "addModelFirst": "请先添加至少一个模型以进行验证" + "addModelFirst": "请先添加至少一个模型以进行验证", + "providers": "提供商", + "addProviderHint": "添加提供商即可开始使用", + "verified": "已验证", + "configuration": "配置", + "displayName": "显示名称", + "awsAccessKeyId": "AWS 访问密钥 ID", + "awsSecretAccessKey": "AWS Secret Access Key", + "awsRegion": "AWS 区域", + "selectRegion": "选择区域", + "apiKey": "API 密钥", + "enterApiKey": "输入您的 API 密钥", + "enterSecretKey": "输入您的 Secret Key", + "baseUrl": "基础 URL", + "optional": "(可选)", + "customEndpoint": "自定义端点 URL", + "models": "模型", + "customModelId": "自定义模型 ID...", + "allAdded": "已全部添加", + "suggested": "推荐", + "noModelsConfigured": "尚未配置模型", + "modelIdEmpty": "模型 ID 不能为空", + "modelIdExists": "此模型 ID 已存在", + "configureProviders": "配置 AI 提供商", + "selectProviderHint": "从列表中选择提供商或添加新的以配置 API 密钥和模型", + "deleteConfirmDesc": "确定要删除 {name} 吗?这将移除所有配置的模型且无法撤销。", + "typeToConfirm": "输入 \"{name}\" 以确认", + "typeProviderName": "输入提供商名称...", + "modelsConfiguredCount": "已配置 {count} 个模型", + "validationFailedCount": "{count} 个模型验证失败", + "cancel": "取消", + "delete": "删除", + "clickToChange": "(点击更改)", + "usingServerDefault": "使用服务器默认模型", + "selectModel": "选择模型", + "searchModels": "搜索模型...", + "noVerifiedModels": "没有已验证的模型。请先测试您的模型。", + "noModelsFound": "未找到模型。", + "default": "默认", + "serverDefault": "服务器默认", + "configureModels": "配置模型...", + "onlyVerifiedShown": "仅显示已验证的模型" } }