Skip to content

Draft: feat(i18n): Refactor Channel Modals (Lot 1) - #1907

Closed
comeback01 wants to merge 9 commits into
QuantumNous:mainfrom
comeback01:feat/i18n-channel-modals
Closed

comeback01 wants to merge 9 commits into
QuantumNous:mainfrom
comeback01:feat/i18n-channel-modals

Conversation

@comeback01

@comeback01 comeback01 commented Sep 28, 2025 •

Copy link
Copy Markdown
Contributor

`markdown
This PR is the first part of the i18n refactoring effort, as tracked in QuantumNous/new-api#XX.

This change handles "Lot 1", which focuses on the channel modal components.

Changes:

  • Replaced hardcoded strings in EditChannelModal.jsx, MultiKeyManageModal.jsx, and EditTagModal.jsx.
  • Added new translation keys to en.json, zh.json, and fr.json.

This is submitted as a draft to get early feedback on the refactoring approach before continuing with the next lots.

Summary by CodeRabbit

  • New Features

    • Added French language option in the header language selector with flag and improved accessibility label.
  • Internationalization

    • Localized many modals and UI texts by replacing hardcoded strings with translation keys; French added to supported languages.
    • Expanded English and Chinese translation keys covering channels, tags, multi-key management, 2FA, and related flows.
  • Documentation

    • Added a full French README and updated README headers to include Français.
  • Tests

    • Added an automated browser test to verify language switching to French.

google-labs-jules Bot and others added 8 commits September 27, 2025 11:18
- Création du fichier de traduction `fr.json` en se basant sur `en.json`.
- Mise à jour de la configuration i18n pour inclure la langue française.
- Modification du sélecteur de langue pour afficher l'option "Français" avec le drapeau correspondant.
- Création du fichier `README.fr.md` en se basant sur `README.en.md`.
- Added `common.changeLanguage` key to `en.json`, `fr.json`, and `zh.json`.
- Updated `LanguageSelector.jsx` to use the new shared key.
- Completed `fr.json` with all keys from `en.json` and `zh.json`.
- Added translations for `closeSidebar`, `pricing`, and `language`.
- Restructured the `common.changeLanguage` key to be nested under a `common` object in `en.json`, `fr.json`, and `zh.json`.
- This change improves the organization of the translation files and aligns with best practices for i18next.
This addresses feedback from CodeRabbitAI by using a regular expression for the language button's aria-label. This ensures the test can run regardless of the browser's default language.
@coderabbitai

coderabbitai Bot commented Sep 28, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds French localization and documentation: new README.fr.md and README header link; registers fr in i18n resources; replaces many hardcoded Chinese UI strings with i18n keys in channel/tag/multi-key modals and language selector; adds a Playwright script to verify switching to Français. Internal helper signature type2secretPrompt(type) → type2secretPrompt(type, t) updated.

Changes

Cohort / File(s) Summary
Documentation
README.md, README.en.md, README.fr.md
Added Français link to README headers and added a full French README (README.fr.md). No runtime changes.
Language selector UI
web/src/components/layout/headerbar/LanguageSelector.jsx
Added French option with FR flag, wired onLanguageChange('fr'), and updated trigger aria-label to t('common.changeLanguage').
Channel / Tag / Multi-key modals i18n
web/src/components/table/channels/modals/EditChannelModal.jsx, .../EditTagModal.jsx, .../MultiKeyManageModal.jsx
Replaced numerous hardcoded Chinese strings with i18n keys; preserved control flow. Updated internal helper signature: type2secretPrompt(type) → type2secretPrompt(type, t).
i18n core & locales
web/src/i18n/i18n.js, web/src/i18n/locales/en.json, web/src/i18n/locales/zh.json, web/src/i18n/locales/fr.json*
Registered fr locale in i18n initialization; extensive additions of translation keys in en.json and zh.json (including common.changeLanguage, modals.tags.*, modals.multiKey.*); one en entry removed. (*fr.json imported/registered)
Verification script
jules-scratch/verification/verify_translation.py
New Playwright script: launches Chromium, navigates to app, opens language menu, selects “Français”, asserts label changes, and captures a screenshot.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant PW as Playwright Script
  participant Browser
  participant App as Web App
  participant I18N as i18n Resources

  Dev->>PW: Run verify_translation.py
  PW->>Browser: Launch headless Chromium
  Browser->>App: GET http://localhost:5173
  App->>I18N: Initialize resources (zh, en, fr)
  PW->>App: Click language button
  PW->>App: Select "Français"
  App->>I18N: Set locale = fr
  I18N-->>App: Provide fr translation strings
  App-->>PW: Render UI with French labels
  PW->>PW: Assert label contains "Français"
  PW->>Browser: Screenshot and close
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

Poem

A rabbit flips the language switch—oh là là!
From 中文 to English, now Français hurrah!
Modals hum in chorus, flags flutter high,
Screenshots wink—“c’est bon!”—and hops goodbye. 🥕🇫🇷

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly conveys the main change by specifying an i18n feature (“feat(i18n): Refactor Channel Modals”) and aligns with the refactoring of channel modal components and addition of translation keys described in the PR.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
web/src/components/table/channels/modals/EditTagModal.jsx (1)

288-296: Chinese literals slipped back into the new translations

Line 291 and Line 295 still hand i18next Chinese strings ('已新增 {{count}} 个模型:{{list}}', '未发现新增模型') as keys. Because those keys are not defined in en/fr locales, the UI will now show the original Chinese text instead of translated copy. Please switch to the namespaced keys you added in the locale files (e.g., modals.tags.addedModels, modals.tags.noNewModelsFound) and port the messages into en/zh/fr to keep the modal localized.

-      showSuccess(
-        t('已新增 {{count}} 个模型:{{list}}', {
+      showSuccess(
+        t('modals.tags.addedModels', {
           count: addedModels.length,
           list: addedModels.join(', '),
         }),
       );
     } else {
-      showInfo(t('未发现新增模型'));
+      showInfo(t('modals.tags.noNewModelsFound'));
     }
web/src/components/table/channels/modals/MultiKeyManageModal.jsx (1)

333-352: Status chips still use Chinese literals as i18n keys

Line 335 onward still calls t('已启用') / t('已禁用') / t('自动禁用') / t('未知状态'). Because those keys are not defined in en/fr locales, the English and French UI will render Chinese text for status tags. Please replace them with the new namespaced keys (for example modals.multiKey.status.enabled, etc.) and ensure the locale files contain the translations.

-            {t('已启用')}
+            {t('modals.multiKey.status.enabled')}
...
-            {t('已禁用')}
+            {t('modals.multiKey.status.manualDisabled')}
...
-            {t('自动禁用')}
+            {t('modals.multiKey.status.autoDisabled')}
...
-            {t('未知状态')}
+            {t('modals.multiKey.status.unknown')}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 045ba23 and a3c565f.

⛔ Files ignored due to path filters (2)
  • bun_output.log is excluded by !**/*.log
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (11)
  • README.en.md (1 hunks)
  • README.fr.md (1 hunks)
  • README.md (1 hunks)
  • jules-scratch/verification/verify_translation.py (1 hunks)
  • web/src/components/layout/headerbar/LanguageSelector.jsx (2 hunks)
  • web/src/components/table/channels/modals/EditChannelModal.jsx (81 hunks)
  • web/src/components/table/channels/modals/EditTagModal.jsx (11 hunks)
  • web/src/components/table/channels/modals/MultiKeyManageModal.jsx (26 hunks)
  • web/src/i18n/i18n.js (2 hunks)
  • web/src/i18n/locales/en.json (1 hunks)
  • web/src/i18n/locales/zh.json (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the applyModelMapping function transforms the models list by replacing original model names (mapping values) with display names (mapping keys). The database stores this transformed list containing mapped keys. On channel load, data.models contains these mapped display names, making the initialization filter if (data.models.includes(key)) correct.

Applied to files:

  • web/src/components/table/channels/modals/EditTagModal.jsx
  • web/src/components/table/channels/modals/EditChannelModal.jsx
  • web/src/components/table/channels/modals/MultiKeyManageModal.jsx
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the database stores mapped keys (display names) in the models field after applying model mapping transformations. When loading a channel, data.models contains the mapped keys, not the original model names. The filtering logic if (data.models.includes(key)) in the initialization is correct.

Applied to files:

  • web/src/components/table/channels/modals/EditTagModal.jsx
  • web/src/components/table/channels/modals/EditChannelModal.jsx
  • web/src/components/table/channels/modals/MultiKeyManageModal.jsx
🧬 Code graph analysis (3)
web/src/components/table/channels/modals/EditChannelModal.jsx (2)
web/src/helpers/utils.jsx (4)
  • showError (122-151)
  • showSuccess (157-159)
  • showInfo (161-163)
  • copy (72-95)
web/src/components/common/ui/JSONEditor.jsx (1)
  • JSONEditor (49-712)
web/src/components/layout/headerbar/LanguageSelector.jsx (1)
web/src/hooks/common/useHeaderBar.js (1)
  • currentLang (39-39)
web/src/components/table/channels/modals/MultiKeyManageModal.jsx (1)
web/src/helpers/utils.jsx (2)
  • showError (122-151)
  • showSuccess (157-159)
🪛 markdownlint-cli2 (0.18.1)
README.fr.md

37-37: Blank line inside blockquote

(MD028, no-blanks-blockquote)

🔇 Additional comments (2)
web/src/components/layout/headerbar/LanguageSelector.jsx (1)

55-58: Good call localizing the trigger’s aria-label

Switching to t('common.changeLanguage') keeps the control accessible in every supported locale.

web/src/i18n/locales/en.json (1)

2132-2324: LGTM! Namespaced channel modal strings look consistent.

Placeholders and escaped characters all match the existing zh keys, so the new structure should wire up cleanly.

@comeback01
comeback01 force-pushed the feat/i18n-channel-modals branch from a3c565f to 425da9e Compare September 28, 2025 12:51

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a3c565f and 425da9e.

📒 Files selected for processing (5)
  • web/src/components/table/channels/modals/EditChannelModal.jsx (81 hunks)
  • web/src/components/table/channels/modals/EditTagModal.jsx (11 hunks)
  • web/src/components/table/channels/modals/MultiKeyManageModal.jsx (28 hunks)
  • web/src/i18n/locales/en.json (1 hunks)
  • web/src/i18n/locales/zh.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/src/components/table/channels/modals/EditTagModal.jsx
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the applyModelMapping function transforms the models list by replacing original model names (mapping values) with display names (mapping keys). The database stores this transformed list containing mapped keys. On channel load, data.models contains these mapped display names, making the initialization filter if (data.models.includes(key)) correct.

Applied to files:

  • web/src/components/table/channels/modals/EditChannelModal.jsx
  • web/src/components/table/channels/modals/MultiKeyManageModal.jsx
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the database stores mapped keys (display names) in the models field after applying model mapping transformations. When loading a channel, data.models contains the mapped keys, not the original model names. The filtering logic if (data.models.includes(key)) in the initialization is correct.

Applied to files:

  • web/src/components/table/channels/modals/EditChannelModal.jsx
  • web/src/components/table/channels/modals/MultiKeyManageModal.jsx
🧬 Code graph analysis (2)
web/src/components/table/channels/modals/EditChannelModal.jsx (2)
web/src/helpers/utils.jsx (4)
  • showError (122-151)
  • showSuccess (157-159)
  • showInfo (161-163)
  • copy (72-95)
web/src/components/common/ui/JSONEditor.jsx (1)
  • JSONEditor (49-712)
web/src/components/table/channels/modals/MultiKeyManageModal.jsx (1)
web/src/helpers/utils.jsx (2)
  • showError (122-151)
  • showSuccess (157-159)

Comment on lines +39 to +112
"modals.tags.modelMappingError": "模型映射必须是合法的 JSON 格式!",
"modals.tags.noChangesWarning": "没有任何修改!",
"modals.tags.tagUpdateSuccess": "标签更新成功!",
"modals.tags.edit": "编辑",
"modals.tags.editTag": "编辑标签",
"modals.tags.save": "保存",
"modals.tags.cancel": "取消",
"modals.tags.tagInfo": "标签信息",
"modals.tags.tagBasicConfig": "标签的基本配置",
"modals.tags.editWarning": "所有编辑均为覆盖操作,留空则不更改",
"modals.tags.tagName": "标签名称",
"modals.tags.newTagPlaceholder": "请输入新标签,留空则解散标签",
"modals.tags.modelConfig": "模型配置",
"modals.tags.modelSelectionAndMapping": "模型选择和映射设置",
"modals.tags.modelListWarning": "当前模型列表为该标签下所有渠道模型列表最长的一个,并非所有渠道的并集,请注意可能导致某些渠道模型丢失。",
"modals.tags.models": "模型",
"modals.tags.modelsPlaceholder": "请选择该渠道所支持的模型,留空则不更改",
"modals.tags.customModelName": "自定义模型名称",
"modals.tags.customModelNamePlaceholder": "输入自定义模型名称",
"modals.tags.add": "填入",
"modals.tags.modelMapping": "模型重定向",
"modals.tags.modelMappingPlaceholder": "此项可选,用于修改请求体中的模型名称,为一个 JSON 字符串,键为请求中模型名称,值为要替换的模型名称,留空则不更改",
"modals.tags.fillTemplate": "填入模板",
"modals.tags.clearRedirect": "清空重定向",
"modals.tags.noChange": "不更改",
"modals.tags.groupSettings": "分组设置",
"modals.tags.userGroupConfig": "用户分组配置",
"modals.tags.groups": "分组",
"modals.tags.groupsPlaceholder": "请选择可以使用该渠道的分组,留空则不更改",
"modals.tags.addGroupHint": "请在系统设置页面编辑分组倍率以添加新的分组:",
"modals.multiKey.getKeyStatusFailed": "获取密钥状态失败",
"modals.multiKey.keyDisabled": "密钥已禁用",
"modals.multiKey.disableKeyFailed": "禁用密钥失败",
"modals.multiKey.keyEnabled": "密钥已启用",
"modals.multiKey.enableKeyFailed": "启用密钥失败",
"modals.multiKey.allKeysEnabled": "已启用所有密钥",
"modals.multiKey.enableAllKeysFailed": "启用所有密钥失败",
"modals.multiKey.allKeysDisabled": "已禁用所有密钥",
"modals.multiKey.disableAllKeysFailed": "禁用所有密钥失败",
"modals.multiKey.deleteDisabledKeysFailed": "删除禁用密钥失败",
"modals.multiKey.keyDeleted": "密钥已删除",
"modals.multiKey.deleteKeyFailed": "删除密钥失败",
"modals.multiKey.columns.index": "索引",
"modals.multiKey.columns.status": "状态",
"modals.multiKey.columns.disableReason": "禁用原因",
"modals.multiKey.columns.disableTime": "禁用时间",
"modals.multiKey.columns.actions": "操作",
"modals.multiKey.actions.disable": "禁用",
"modals.multiKey.actions.enable": "启用",
"modals.multiKey.confirmDeleteKeyTitle": "确定要删除此密钥吗?",
"modals.multiKey.confirmDeleteKeyContent": "此操作不可撤销,将永久删除该密钥",
"modals.multiKey.actions.delete": "删除",
"modals.multiKey.title": "多密钥管理",
"modals.multiKey.totalKeys": "总密钥数",
"modals.multiKey.randomMode": "随机模式",
"modals.multiKey.pollingMode": "轮询模式",
"modals.multiKey.stats.enabled": "已启用",
"modals.multiKey.stats.manualDisabled": "手动禁用",
"modals.multiKey.stats.autoDisabled": "自动禁用",
"modals.multiKey.filters.allStatus": "全部状态",
"modals.multiKey.filters.enabled": "已启用",
"modals.multiKey.filters.manualDisabled": "手动禁用",
"modals.multiKey.filters.autoDisabled": "自动禁用",
"modals.multiKey.actions.refresh": "刷新",
"modals.multiKey.confirmEnableAllTitle": "确定要启用所有密钥吗?",
"modals.multiKey.actions.enableAll": "启用全部",
"modals.multiKey.confirmDisableAllTitle": "确定要禁用所有的密钥吗?",
"modals.multiKey.actions.disableAll": "禁用全部",
"modals.multiKey.confirmDeleteAutoDisabledTitle": "确定要删除所有已自动禁用的密钥吗?",
"modals.multiKey.confirmDeleteAutoDisabledContent": "此操作不可撤销,将永久删除已自动禁用的密钥",
"modals.multiKey.deleteAutoDisabledKeys": "删除自动禁用密钥",
"modals.multiKey.noKeyDataTitle": "暂无密钥数据",
"modals.multiKey.noKeyDataDescription": "请检查渠道配置或刷新重试"
} No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Restore zh translations for channel modal keys

EditChannelModal.jsx now replaces all hardcoded text with t('modals.channels.edit.*'), and en.json supplies those keys. However, zh.json still lacks the entire modals.channels.edit block, so the zh locale will fall back to English strings throughout the channel modal. Please port the original Chinese copy into matching modals.channels.edit.* entries (and keep it in sync with en/fr) to avoid a localized UI regression.

🤖 Prompt for AI Agents
In web/src/i18n/locales/zh.json around lines 39 to 112, the entire
"modals.channels.edit.*" translation block is missing causing zh to fall back to
English; restore the full set of keys matching en.json under
"modals.channels.edit" with the original Chinese strings (port the Chinese copy
previously used in the channel modal), keeping key names identical to en.json
and values as Chinese translations, then run the i18n lint/build or a quick UI
check to ensure the channel modal displays localized text.

Replaces hardcoded strings in EditChannelModal, MultiKeyManageModal, and EditTagModal. Adds i18n keys for English, Chinese, and French.
@comeback01
comeback01 force-pushed the feat/i18n-channel-modals branch from 425da9e to a91aaf2 Compare September 28, 2025 13:26

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
web/src/components/table/channels/modals/EditTagModal.jsx (2)

274-279: Option item uses text instead of label (will render blank labels).

Semi UI optionList expects { label, value }. Using text breaks display and search.

Apply this diff:

-        localModelOptions.push({
-          key: model,
-          text: model,
-          value: model,
-        });
+        localModelOptions.push({
+          key: model,
+          label: model,
+          value: model,
+        });

161-192: Add missing modals.tags.* i18n entries to en.json and fr.json
All 31 keys referenced in EditTagModal.jsx (e.g. modals.tags.add, modals.tags.editTag, modals.tags.noChangesWarning, etc.) are present only in zh.json – they must be added under modals.tags in web/src/i18n/locales/en.json and fr.json to avoid raw-key fallbacks.

🧹 Nitpick comments (8)
web/src/components/table/channels/modals/MultiKeyManageModal.jsx (1)

350-353: Use a namespaced i18n key for “unknown status”.

Avoid using a literal Chinese key. Add and use modals.multiKey.stats.unknown for consistency with the rest of this modal.

Apply this diff:

-          <Tag color='grey' shape='circle' size='small'>
-            {t('未知状态')}
-          </Tag>
+          <Tag color='grey' shape='circle' size='small'>
+            {t('modals.multiKey.stats.unknown')}
+          </Tag>
web/src/components/table/channels/modals/EditTagModal.jsx (2)

288-296: Un-namespaced Chinese keys in t(); use modals.tags.*.

Replace literal keys to keep the i18n surface consistent with this PR.

Apply this diff:

-      showSuccess(
-        t('已新增 {{count}} 个模型:{{list}}', {
+      showSuccess(
+        t('modals.tags.addedModels', {
           count: addedModels.length,
           list: addedModels.join(', '),
         }),
       );
     } else {
-      showInfo(t('未发现新增模型'));
+      showInfo(t('modals.tags.noNewModelsFound'));
     }

Also applies to: 295-296


82-129: Dead code: type-based model presets don’t apply in Tag editing.

The form never sets type, so this branch never runs. Removing it reduces cognitive load.

web/src/i18n/locales/en.json (4)

2351-2354: Add an i18n string for unknown key status.

Used by MultiKeyManageModal’s default tag.

Apply this diff near other modals.multiKey.stats.* keys:

   "modals.multiKey.stats.autoDisabled": "Auto disabled",
+  "modals.multiKey.stats.unknown": "Unknown status",

2218-2231: Add label key for “Account ID”.

EditChannelModal currently hardcodes the label. Add the key so UI can localize it.

Apply this diff in the channels edit block:

+ "modals.channels.edit.accountId": "Account ID",

2131-2368: Ensure Tag modal keys exist (at least those newly referenced).

If not already present, add minimal keys to back your changes in EditTagModal.

Apply this diff (minimal set):

+ "modals.tags": {
+   "addedModels": "Added {{count}} models: {{list}}",
+   "noNewModelsFound": "No new models were added",
+   "modelMappingError": "Model mapping must be valid JSON",
+   "noChangesWarning": "You seem to have not modified anything",
+   "tagUpdateSuccess": "Tag updated successfully",
+   "edit": "Edit",
+   "editTag": "Edit Tag",
+   "save": "Save",
+   "cancel": "Cancel",
+   "tagInfo": "Tag Information",
+   "tagBasicConfig": "Tag basic configuration",
+   "editWarning": "All edits overwrite existing settings; leave blank to keep unchanged.",
+   "tagName": "Tag Name",
+   "newTagPlaceholder": "Enter new tag name (leave unchanged to keep)",
+   "modelConfig": "Model Configuration",
+   "modelSelectionAndMapping": "Model selection and mapping",
+   "modelListWarning": "Selecting models will overwrite the tag's model list.",
+   "models": "Models",
+   "modelsPlaceholder": "Select models (leave empty to keep)",
+   "customModelName": "Custom model names",
+   "customModelNamePlaceholder": "Comma-separated model names",
+   "add": "Add",
+   "modelMapping": "Model mapping",
+   "modelMappingPlaceholder": "Optional JSON: { \"requested\": \"actual\" }",
+   "fillTemplate": "Fill template",
+   "clearRedirect": "Clear redirect",
+   "noChange": "No change",
+   "groupSettings": "Group Settings",
+   "userGroupConfig": "User Group Configuration",
+   "groups": "Groups",
+   "groupsPlaceholder": "Select groups (leave empty to keep)",
+   "addGroupHint": "Type to add a group"
+ },

1-2100: Mixed style: top-level Chinese keys and namespaced keys.

Longer term, converge on namespaced English keys (common.*, modals.*) to simplify maintenance and translation workflows.

web/src/components/table/channels/modals/EditChannelModal.jsx (1)

1739-1745: Localize “Account ID” label.

Use an i18n key and add it to locales (see en.json comment).

Apply this diff:

-                      label='Account ID'
+                      label={t('modals.channels.edit.accountId')}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 425da9e and a91aaf2.

📒 Files selected for processing (5)
  • web/src/components/table/channels/modals/EditChannelModal.jsx (81 hunks)
  • web/src/components/table/channels/modals/EditTagModal.jsx (11 hunks)
  • web/src/components/table/channels/modals/MultiKeyManageModal.jsx (28 hunks)
  • web/src/i18n/locales/en.json (1 hunks)
  • web/src/i18n/locales/zh.json (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the applyModelMapping function transforms the models list by replacing original model names (mapping values) with display names (mapping keys). The database stores this transformed list containing mapped keys. On channel load, data.models contains these mapped display names, making the initialization filter if (data.models.includes(key)) correct.

Applied to files:

  • web/src/components/table/channels/modals/EditTagModal.jsx
  • web/src/components/table/channels/modals/EditChannelModal.jsx
📚 Learning: 2025-08-27T02:15:25.448Z
Learnt from: AAEE86
PR: QuantumNous/new-api#1658
File: web/src/components/table/channels/modals/EditChannelModal.jsx:555-569
Timestamp: 2025-08-27T02:15:25.448Z
Learning: In EditChannelModal.jsx, the database stores mapped keys (display names) in the models field after applying model mapping transformations. When loading a channel, data.models contains the mapped keys, not the original model names. The filtering logic if (data.models.includes(key)) in the initialization is correct.

Applied to files:

  • web/src/components/table/channels/modals/EditChannelModal.jsx
🧬 Code graph analysis (3)
web/src/components/table/channels/modals/EditTagModal.jsx (2)
web/src/helpers/utils.jsx (3)
  • showInfo (161-163)
  • showWarning (153-155)
  • showSuccess (157-159)
web/src/components/table/channels/modals/EditChannelModal.jsx (2)
  • addCustomModels (970-1004)
  • handleInputChange (289-364)
web/src/components/table/channels/modals/EditChannelModal.jsx (2)
web/src/helpers/utils.jsx (4)
  • showError (122-151)
  • showSuccess (157-159)
  • showInfo (161-163)
  • copy (72-95)
web/src/components/common/ui/JSONEditor.jsx (1)
  • JSONEditor (49-712)
web/src/components/table/channels/modals/MultiKeyManageModal.jsx (2)
web/src/helpers/utils.jsx (2)
  • showError (122-151)
  • showSuccess (157-159)
web/src/components/settings/RatioSetting.jsx (1)
  • onRefresh (90-99)
🔇 Additional comments (4)
web/src/components/table/channels/modals/MultiKeyManageModal.jsx (1)

611-619: Verify Select uses null as an option value.

Some Select implementations coerce null and can emit string "null" or treat it as uncontrolled. Confirm Semi UI behavior here; if flaky, switch to a sentinel like 'all' and map it to null before the API call.

Also applies to: 612-619

web/src/components/table/channels/modals/EditChannelModal.jsx (2)

281-287: Two similar fields: setting vs settings. Verify intent.

setting (extra settings JSON) and settings (other settings like azure_responses_version) are both used. Confirm both are needed and documented to prevent future confusion.

Also applies to: 438-457


221-231: Modal state reset looks solid.

Nice comprehensive cleanup of form and 2FA states on close; reduces bleed-over between openings.

Also applies to: 744-746

web/src/i18n/locales/zh.json (1)

39-112: Still missing modals.channels.edit.* translations

EditChannelModal.jsx now reads t('modals.channels.edit.*'), but zh.json still doesn’t define that namespace, so the entire channel modal falls back to English in Chinese locale. Please port the original Chinese strings (matching the key structure in en.json/fr.json) into a modals.channels.edit block to avoid the regression.

Comment on lines 1569 to 1574
isEdit
? t('密钥(编辑模式下,保存的密钥不会显示)')
: t('密钥')
? t('modals.channels.edit.keyEditMode')
: t('modals.channels.edit.key')
}
placeholder={t(type2secretPrompt(inputs.type))}
placeholder={t(type2secretPrompt(inputs.type, t))}
rules={

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Double-translation: avoid t(t('...')).

type2secretPrompt(type, t) already returns a localized string. Don’t pass it back into t().

Apply this diff:

-                          placeholder={t(type2secretPrompt(inputs.type, t))}
+                          placeholder={type2secretPrompt(inputs.type, t)}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
isEdit
? t('密钥(编辑模式下,保存的密钥不会显示)')
: t('密钥')
? t('modals.channels.edit.keyEditMode')
: t('modals.channels.edit.key')
}
placeholder={t(type2secretPrompt(inputs.type))}
placeholder={t(type2secretPrompt(inputs.type, t))}
rules={
}
placeholder={type2secretPrompt(inputs.type, t)}
rules={
🤖 Prompt for AI Agents
In web/src/components/table/channels/modals/EditChannelModal.jsx around lines
1569 to 1574, the placeholder value is being double-translated by calling
t(type2secretPrompt(inputs.type, t)); change it to use the already-localized
string returned by type2secretPrompt directly (i.e., pass the result as the
placeholder without wrapping it in t()), so set the placeholder to
type2secretPrompt(inputs.type, t).

@comeback01 comeback01 closed this Sep 28, 2025
@comeback01
comeback01 deleted the feat/i18n-channel-modals branch September 28, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant