From 2d1a15b196bee22edefa9429857b822e1dd2c067 Mon Sep 17 00:00:00 2001 From: ianshaw Date: Thu, 25 Dec 2025 21:25:08 -0800 Subject: [PATCH] =?UTF-8?q?feat(frontend):=20=E6=B7=BB=E5=8A=A0=20Gemini?= =?UTF-8?q?=20OAuth=20=E7=B1=BB=E5=9E=8B=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - zh.ts: 添加中文翻译(Code Assist/AI Studio 选择等) - en.ts: 添加英文翻译 --- frontend/src/i18n/locales/en.ts | 75 ++++++++++++++++++++------------- frontend/src/i18n/locales/zh.ts | 68 ++++++++++++++++++------------ 2 files changed, 85 insertions(+), 58 deletions(-) diff --git a/frontend/src/i18n/locales/en.ts b/frontend/src/i18n/locales/en.ts index 031923a1..c45b99ff 100644 --- a/frontend/src/i18n/locales/en.ts +++ b/frontend/src/i18n/locales/en.ts @@ -923,40 +923,55 @@ export default { 'You can copy the entire URL or just the code parameter value, the system will auto-detect' }, // Gemini specific - gemini: { - title: 'Gemini Account Authorization', - followSteps: 'Follow these steps to authorize your Gemini account:', - step1GenerateUrl: 'Generate the authorization URL (requires a redirect URI)', - generateAuthUrl: 'Generate Auth URL', - step2OpenUrl: 'Open the URL in your browser and complete authorization', - openUrlDesc: - 'Open the authorization URL in a new tab, log in to your Google account and authorize.', - step3EnterCode: 'Enter Authorization URL or Code', - authCodeDesc: - 'After authorization, you will be redirected to the redirect URI with code and state. Paste the full URL or just the code below:', - authCode: 'Authorization URL or Code', - authCodePlaceholder: - 'Option 1: Paste the complete callback URL\n(https://your-domain/auth/callback?code=...&state=...)\nOption 2: Paste only the code value', - authCodeHint: - 'If you paste the full URL, the system will auto-extract code/state for you', + gemini: { + title: 'Gemini Account Authorization', + followSteps: 'Follow these steps to authorize your Gemini account:', + step1GenerateUrl: 'Generate the authorization URL', + generateAuthUrl: 'Generate Auth URL', + projectIdLabel: 'Project ID (optional)', + projectIdPlaceholder: 'e.g. my-gcp-project or cloud-ai-companion-xxxxx', + projectIdHint: + 'Leave empty to auto-detect after code exchange. If auto-detection fails, fill it in and re-generate the auth URL to try again.', + howToGetProjectId: 'How to get', + step2OpenUrl: 'Open the URL in your browser and complete authorization', + openUrlDesc: + 'Open the authorization URL in a new tab, log in to your Google account and authorize.', + step3EnterCode: 'Enter Authorization URL or Code', + authCodeDesc: + 'After authorization, copy the callback URL (recommended) or just the code and paste it below.', + authCode: 'Callback URL or Code', + authCodePlaceholder: + 'Option 1 (recommended): Paste the callback URL\nOption 2: Paste only the code value', + authCodeHint: 'The system will auto-extract code/state from the URL.', redirectUri: 'Redirect URI', redirectUriHint: 'This must be configured in your Google OAuth client and must match exactly.', confirmRedirectUri: 'I have configured this Redirect URI in the Google OAuth client (must match exactly)', - invalidRedirectUri: 'Redirect URI must be a valid http(s) URL', - redirectUriNotConfirmed: 'Please confirm the Redirect URI is configured correctly', - missingRedirectUri: 'Missing redirect URI', - failedToGenerateUrl: 'Failed to generate Gemini auth URL', - missingExchangeParams: 'Missing auth code, session ID, state, or redirect URI', - failedToExchangeCode: 'Failed to exchange Gemini auth code', - modelPassthrough: 'Gemini Model Passthrough', - modelPassthroughDesc: - 'All model requests are forwarded directly to the Gemini API without model restrictions or mappings.', - stateWarningTitle: '⚠️ Important: Gemini requires both code and state', - stateWarningDesc: - 'We recommend pasting the complete callback URL so the system can auto-extract both code and state. Pasting only the code will cause authorization to fail.' - } + invalidRedirectUri: 'Redirect URI must be a valid http(s) URL', + redirectUriNotConfirmed: 'Please confirm the Redirect URI is configured correctly', + missingRedirectUri: 'Missing redirect URI', + failedToGenerateUrl: 'Failed to generate Gemini auth URL', + missingExchangeParams: 'Missing auth code, session ID, or state', + failedToExchangeCode: 'Failed to exchange Gemini auth code', + modelPassthrough: 'Gemini Model Passthrough', + modelPassthroughDesc: + 'All model requests are forwarded directly to the Gemini API without model restrictions or mappings.', + stateWarningTitle: 'Note', + stateWarningDesc: 'Recommended: paste the full callback URL (includes code & state).', + oauthTypeLabel: 'OAuth Type', + needsProjectId: 'For GCP Developers', + needsProjectIdDesc: 'Uses built-in client, requires GCP project', + noProjectIdNeeded: 'For Regular Users', + noProjectIdNeededDesc: 'Requires your own OAuth client' + } + }, + // Gemini specific (platform-wide) + gemini: { + modelPassthrough: 'Gemini Model Passthrough', + modelPassthroughDesc: + 'All model requests are forwarded directly to the Gemini API without model restrictions or mappings.', + apiKeyHint: 'Your Gemini API Key (starts with AIza)' }, // Re-Auth Modal reAuthorizeAccount: 'Re-Authorize Account', @@ -983,7 +998,7 @@ export default { startingTestForAccount: 'Starting test for account: {name}', testAccountTypeLabel: 'Account type: {type}', selectTestModel: 'Select Test Model', - testModel: 'claude-sonnet-4-5-20250929', + testModel: 'Test model', testPrompt: 'Prompt: "hi"', // Stats Modal viewStats: 'View Stats', diff --git a/frontend/src/i18n/locales/zh.ts b/frontend/src/i18n/locales/zh.ts index b309e8a6..5ffe0d94 100644 --- a/frontend/src/i18n/locales/zh.ts +++ b/frontend/src/i18n/locales/zh.ts @@ -1038,35 +1038,47 @@ export default { authCodeHint: '您可以直接复制整个链接或仅复制 code 参数值,系统会自动识别' }, // Gemini specific - gemini: { - title: 'Gemini 账户授权', - followSteps: '请按照以下步骤完成 Gemini 账户的授权:', - step1GenerateUrl: '先配置 Redirect URI,然后生成授权链接', - generateAuthUrl: '生成授权链接', - step2OpenUrl: '在浏览器中打开链接并完成授权', - openUrlDesc: '请在新标签页中打开授权链接,登录您的 Google 账户并授权。', - step3EnterCode: '输入回调链接或 Code', - authCodeDesc: - '授权完成后会跳转到 Redirect URI,并带上 codestate 参数。请粘贴完整链接或仅粘贴 code:', - authCode: '回调链接或 Code', - authCodePlaceholder: - '方式1:粘贴完整回调链接\n(https://your-domain/auth/callback?code=...&state=...)\n方式2:仅粘贴 code 参数的值', - authCodeHint: '如果粘贴完整链接,系统会自动提取 code/state', + gemini: { + title: 'Gemini 账户授权', + followSteps: '请按照以下步骤完成 Gemini 账户的授权:', + step1GenerateUrl: '生成授权链接', + generateAuthUrl: '生成授权链接', + projectIdLabel: 'Project ID(可选)', + projectIdPlaceholder: '例如:my-gcp-project 或 cloud-ai-companion-xxxxx', + projectIdHint: '留空则在兑换授权码后自动探测;若自动探测失败,可填写后重新生成授权链接再授权。', + howToGetProjectId: '如何获取', + step2OpenUrl: '在浏览器中打开链接并完成授权', + openUrlDesc: '请在新标签页中打开授权链接,登录您的 Google 账户并授权。', + step3EnterCode: '输入回调链接或 Code', + authCodeDesc: '授权完成后,复制浏览器跳转后的回调链接(推荐)或仅复制 code,粘贴到下方即可。', + authCode: '回调链接或 Code', + authCodePlaceholder: '方式1(推荐):粘贴回调链接\n方式2:仅粘贴 code 参数的值', + authCodeHint: '系统会自动从链接中解析 code/state。', redirectUri: 'Redirect URI', redirectUriHint: '需要在 Google OAuth Client 中配置,且必须与此处完全一致。', confirmRedirectUri: '我已在 Google OAuth Client 中配置了该 Redirect URI(必须完全一致)', invalidRedirectUri: 'Redirect URI 必须是合法的 http(s) URL', - redirectUriNotConfirmed: '请确认 Redirect URI 已在 Google OAuth Client 中正确配置', - missingRedirectUri: '缺少 Redirect URI', - failedToGenerateUrl: '生成 Gemini 授权链接失败', - missingExchangeParams: '缺少 code / session_id / state / redirect_uri', - failedToExchangeCode: 'Gemini 授权码兑换失败', - modelPassthrough: 'Gemini 直接转发模型', - modelPassthroughDesc: '所有模型请求将直接转发至 Gemini API,不进行模型限制或映射。', - stateWarningTitle: '⚠️ 重要:Gemini 需要 code 和 state 参数', - stateWarningDesc: - '建议直接粘贴完整的回调链接,系统会自动提取 code 和 state。如果只粘贴 code,授权将会失败。' - } + redirectUriNotConfirmed: '请确认 Redirect URI 已在 Google OAuth Client 中正确配置', + missingRedirectUri: '缺少 Redirect URI', + failedToGenerateUrl: '生成 Gemini 授权链接失败', + missingExchangeParams: '缺少 code / session_id / state', + failedToExchangeCode: 'Gemini 授权码兑换失败', + modelPassthrough: 'Gemini 直接转发模型', + modelPassthroughDesc: '所有模型请求将直接转发至 Gemini API,不进行模型限制或映射。', + stateWarningTitle: '提示', + stateWarningDesc: '建议粘贴完整回调链接(包含 code 和 state)。', + oauthTypeLabel: 'OAuth 类型', + needsProjectId: '适合 GCP 开发者', + needsProjectIdDesc: '使用内置客户端,需 GCP 项目', + noProjectIdNeeded: '适合普通用户', + noProjectIdNeededDesc: '需自建 OAuth Client' + } + }, + // Gemini specific (platform-wide) + gemini: { + modelPassthrough: 'Gemini 直接转发模型', + modelPassthroughDesc: '所有模型请求将直接转发至 Gemini API,不进行模型限制或映射。', + apiKeyHint: 'Your Gemini API Key(以 AIza 开头)' }, // Re-Auth Modal reAuthorizeAccount: '重新授权账号', @@ -1090,9 +1102,9 @@ export default { copyOutput: '复制输出', startingTestForAccount: '开始测试账号:{name}', testAccountTypeLabel: '账号类型:{type}', - selectTestModel: '选择测试模型', - testModel: 'claude-sonnet-4-5-20250929', - testPrompt: '提示词:"hi"', + selectTestModel: '选择测试模型', + testModel: '测试模型', + testPrompt: '提示词:"hi"', // Stats Modal viewStats: '查看统计', usageStatistics: '使用统计',