Skip to content

fix: 修复新 UI 语言与文案显示问题#4876

Merged
Calcium-Ion merged 6 commits into
mainfrom
perf-new-ui
May 17, 2026
Merged

fix: 修复新 UI 语言与文案显示问题#4876
Calcium-Ion merged 6 commits into
mainfrom
perf-new-ui

Conversation

@QuentinHsu
Copy link
Copy Markdown
Collaborator

@QuentinHsu QuentinHsu commented May 15, 2026

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

  • Closes # (如有)

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

(请在此粘贴截图、关键日志或测试报告,以证明变更生效)

问题描述

  • 新 UI 中部分界面语言选项在不同入口维护,可能导致标签和当前选中状态不一致。
  • 部分前端文案、表单错误和渠道操作 fallback 文案没有完整接入 i18n。
  • 聊天预设菜单中的长名称可能挤压外部打开图标或加载图标。
  • 本地开发缺少更方便的后端重建和 setup 状态重置入口。

修复方式

  • 新增共享的界面语言配置与归一化逻辑,并复用于语言切换器和个人语言偏好卡片。
  • 补齐六种语言的缺失翻译键,并更新 i18n 同步报告。
  • 让通用表单错误消息走 t() 翻译,并补齐渠道测试、多 key 管理和凭证刷新等 fallback 文案。
  • 为聊天预设名称添加截断布局,并固定操作图标尺寸。
  • 在 makefile 中补充后端 dev rebuild 和本地 setup reset 目标。

测试说明

  • 分支 diff 未包含自动化测试文件变更。
  • i18n 同步报告显示各 locale missingCount 为 0。

Summary by CodeRabbit

Release Notes

  • New Features

    • Added compliance confirmation workflow with gating for payments, subscriptions, and rewards until terms are acknowledged.
  • Improvements

    • Form messages and error messages now properly translated across all supported languages.
    • Enhanced language settings with improved normalization and centralized configuration.
    • Chat preset names now display with proper text truncation to prevent layout overflow.
  • Localization

    • Expanded translation coverage across Chinese, English, French, Russian, Japanese, and Vietnamese locales.

Review Change Stack

- add a reset-setup make target to clear setup records, root users, and related options.
- support both docker dev PostgreSQL and local SQLite development databases.
- restart the docker dev backend so setup status is recalculated after reset.
- add truncation layout for chat preset names to keep long labels inside the sidebar menu.
- prevent loading and external-link icons from shrinking in constrained menu rows.
- call t() for granularity option labels in dashboard system settings.
- keep localized text consistent between the select trigger and dropdown items.
- add a dev-api-rebuild make target to rebuild and start the docker backend service.
- reuse DEV_COMPOSE_FILE and DEV_BACKEND_SERVICE variables to avoid repeated compose config literals.
- add shared interface language options to keep display names consistent.
- reuse the shared options in the header switcher and profile preferences.
- normalize language codes so zh-CN and zh_CN resolve to Simplified Chinese.
- route channel key prompts, form validation messages, and channel fallback text through i18n.
- add missing translations across six locales for channels, rankings, billing, and logs.
- update i18n sync reports so literal t() keys are present in the base locale.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

Walkthrough

This PR consolidates language handling by introducing a @/i18n/languages module with normalized language configuration, refactors two UI components to use this shared module, adds i18n translation to form error messages and operation fallbacks across multiple components, and expands English and five non-English locale files with 49 new or updated translation entries covering compliance confirmation workflows, UI labels, and error messages. Development infrastructure changes add Makefile configuration variables for dev environment setup and a new reset-setup target to clear local wizard state.

Changes

Internationalization and Component Refactoring

Layer / File(s) Summary
Language configuration module
web/default/src/i18n/languages.ts
New module exporting INTERFACE_LANGUAGE_OPTIONS (zh, en, fr, ru, ja, vi), InterfaceLanguageCode type, and normalizeInterfaceLanguage() helper that sanitizes input, validates codes, and defaults to English.
Component language switching refactoring
web/default/src/components/language-switcher.tsx, web/default/src/features/profile/components/language-preferences-card.tsx
Both components replace local language lists and normalizers with imports from the shared language module, using normalizeInterfaceLanguage() and INTERFACE_LANGUAGE_OPTIONS for consistent language handling.
Error message and form translation integration
web/default/src/components/ui/form.tsx, web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx, web/default/src/features/channels/components/dialogs/multi-key-manage-dialog.tsx, web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx, web/default/src/features/system-settings/content/dashboard-section.tsx, web/default/src/i18n/static-keys.ts
FormMessage uses i18n translation for message body; channel/form operations now use translated fallback messages (t(...)) instead of hardcoded English strings when API responses lack messages.
UI component rendering updates
web/default/src/components/layout/components/chat-presets-item.tsx
Chat preset names wrapped in truncating span elements; icon sizing classes adjusted for proper layout and animation.
English locale expansion
web/default/src/i18n/locales/en.json
49 new/updated entries: compliance confirmation strings, UI labels (Click to view image, Payment, Test failed, Enter API key for this channel), error messages (Failed to confirm compliance, Failed to fetch channel key, etc.), legal acknowledgment text, and compliance-gating messages for payment/redemption/subscription/invitation features.
French locale expansion
web/default/src/i18n/locales/fr.json
49 new/updated French translations mirroring English expansion with compliance confirmation, UI labels, error messages, legal statements, and feature-gating text.
Japanese locale expansion
web/default/src/i18n/locales/ja.json
49 new/updated entries with Japanese translations for compliance UI and acknowledgment statements; several long-form compliance entries stored in English pending full translation.
Russian locale expansion
web/default/src/i18n/locales/ru.json
49 new/updated Russian translations for compliance confirmation flows, UI labels, error messages, and legal acknowledgment text; select compliance statements stored in English.
Vietnamese locale expansion
web/default/src/i18n/locales/vi.json
49 new/updated Vietnamese translations introducing compliance confirmation UI, legal acknowledgment text, and feature-gating messages; many entries mirror English keys awaiting translation.
Chinese locale expansion
web/default/src/i18n/locales/zh.json
49 new/updated Chinese translations for compliance confirmation dialogs, legal acknowledgment, feature-gating messages, UI labels, and operational text aligned with international expansion.
Translation coverage metrics
web/default/src/i18n/locales/_reports/_sync-report.json, web/default/src/i18n/locales/_reports/fr.untranslated.json, web/default/src/i18n/locales/_reports/ja.untranslated.json, web/default/src/i18n/locales/_reports/ru.untranslated.json, web/default/src/i18n/locales/_reports/vi.untranslated.json
Sync report updated with new untranslated counts (fr: 1→21, ja: 92→120, ru: 107→135, vi: 3→23); untranslated reports expanded with compliance-related string keys for each non-English locale.

Development Infrastructure

Layer / File(s) Summary
Dev environment configuration
makefile
Adds variables for compose file (DEV_COMPOSE_FILE), service names (DEV_POSTGRES_SERVICE, DEV_BACKEND_SERVICE), database credentials (DEV_POSTGRES_DB, DEV_POSTGRES_USER), and SQLite path (DEV_SQLITE_PATH); updates dev-api to use configurable compose file and adds dev-api-rebuild target.
Reset setup state target
makefile
New reset-setup target clears local wizard state: detects running Postgres dev container and executes SQL deletions against setups/users/options, then restarts backend; falls back to SQLite deletion if Postgres unavailable.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • Calcium-Ion

A rabbit hops through languages bright,
From east to west with translations in flight! 🐰🌍
Compliance confirmed across every tongue,
Where setup resets keep the dev work young! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: 修复新 UI 语言与文案显示问题' (fix: Fix new UI language and copy display issues) accurately summarizes the main changes, which involve fixing language-related UI issues and display problems across multiple components and translations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf-new-ui

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 9

🧹 Nitpick comments (3)
web/default/src/i18n/locales/en.json (1)

799-801: 🏗️ Heavy lift

Use hierarchical i18n keys for the newly added entries.

These newly added translation keys use full English sentences as key names, which diverges from the required semantic/hierarchical key convention and will keep key management brittle across locales and refactors.

As per coding guidelines, "Use hierarchical and semantically clear translation key names such as dashboard.overview.title and maintain naming consistency".

Also applies to: 877-878, 1575-1575, 2872-2872, 3194-3194, 3205-3205, 3744-3744, 3900-3900, 4442-4451

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/default/src/i18n/locales/en.json` around lines 799 - 801, The JSON uses
sentence strings as translation keys; rename the three keys "Compliance
confirmation required", "Compliance confirmed", and "Compliance confirmed
successfully" to hierarchical semantic keys (for example
compliance.confirmation.required, compliance.confirmed,
compliance.confirmed.success), move the original English strings to the values,
and update all code references to use the new keys; also scan and convert the
other sentence-like keys mentioned in your comment to consistent hierarchical
keys (e.g., module.submodule.descriptiveName) and update their usages across the
codebase so keys remain semantic and refactor-safe.
web/default/src/components/layout/components/chat-presets-item.tsx (2)

100-102: 💤 Low value

Consider adding a title attribute for accessibility.

Similar to the web preset case, truncated external preset names should provide the full text via a title attribute for better user experience.

♻️ Proposed enhancement
       <SidebarMenuSubButton
+        title={preset.name}
         onClick={() => {
           if (!loading) void onOpen(preset)

Optional: Remove redundant whitespace-nowrap class.

The truncate utility already includes white-space: nowrap.

Minor cleanup
-        <span className='min-w-0 flex-1 truncate whitespace-nowrap'>
+        <span className='min-w-0 flex-1 truncate'>
           {preset.name}
         </span>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/default/src/components/layout/components/chat-presets-item.tsx` around
lines 100 - 102, In the ChatPresetsItem component, the span that renders
{preset.name} should include a title attribute so truncated external preset
names are readable on hover; update the span in chat-presets-item.tsx (the
element with className 'min-w-0 flex-1 truncate whitespace-nowrap') to add
title={preset.name} and optionally remove the redundant 'whitespace-nowrap'
class since 'truncate' already applies nowrap.

82-84: 💤 Low value

Consider adding a title attribute for accessibility.

Truncated preset names may hide important information from users. Adding a title attribute would allow users to view the full name on hover.

♻️ Proposed enhancement
-        <SidebarMenuSubButton
+        <SidebarMenuSubButton
+          title={preset.name}
           isActive={active}
           render={
             <Link

Optional: Remove redundant whitespace-nowrap class.

The truncate utility already includes white-space: nowrap, making the whitespace-nowrap class redundant.

Minor cleanup
-          <span className='min-w-0 flex-1 truncate whitespace-nowrap'>
+          <span className='min-w-0 flex-1 truncate'>
             {preset.name}
           </span>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/default/src/components/layout/components/chat-presets-item.tsx` around
lines 82 - 84, Add a title attribute to the span that displays the preset name
so truncated names are readable on hover (use the same value as preset.name);
update the element in chat-presets-item.tsx where preset.name is rendered (the
span with class 'min-w-0 flex-1 truncate') to include title={preset.name}. Also
remove the redundant 'whitespace-nowrap' class from that span since the
'truncate' utility already applies nowrap.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@makefile`:
- Around line 49-64: Add fail-fast and transactional guards to the reset-setup
target: enable shell fail-fast by prefixing the multi-line recipe branches with
"set -e;" and for the Postgres branch call psql with ON_ERROR_STOP (psql -v
ON_ERROR_STOP=1) and wrap the SQL in a transaction (BEGIN; ...; COMMIT;), and
for the SQLite branch wrap the statements in a transaction (BEGIN TRANSACTION;
...; COMMIT;) so any SQL error aborts and prevents the subsequent echo/restart
steps; locate and modify the Docker/Postgres exec line that invokes psql and the
sqlite3 invocation to include these changes.

In `@web/default/src/i18n/locales/fr.json`:
- Line 9: The French locale has the English conjunction as the value for the key
",and " which will produce English text in French UI; update the mapping for the
JSON key ",and " in fr.json to the correct French conjunction value (e.g., ", et
"), save the file and re-run any i18n build/validation so the change propagates
(look specifically for the ",and " entry in fr.json to locate and edit it).
- Around line 799-801: The French locale contains untranslated UX/compliance
strings; locate the keys "Compliance confirmation required", "Compliance
confirmed", and "Compliance confirmed successfully" (and the other untranslated
keys noted around lines 869-878, 891-895, 1575, 1988-1989, 2001, 2640, 2872,
3194, 3205, 3744, 3900, and 4442-4451) in web/default/src/i18n/locales/fr.json
and replace the English values with accurate French translations that preserve
tone and legal meaning; ensure pluralization/variables (if any) remain intact
and run the localization linter/CI to validate JSON and coverage after updating
all affected keys.

In `@web/default/src/i18n/locales/ja.json`:
- Line 123: The Japanese locale contains untranslated English keys (e.g., the
string "acknowledge the related legal risks" in ja.json) used in the
compliance/payment gating flow; replace these English values with accurate
Japanese translations for all listed occurrences (including ranges 799-801, 869,
877-895, 1575, 1988-2002, 2640, 2872, 2966, 3194-3205, 3744, 3868, 3900, 4102,
4442-4451) and ensure any exact-match confirmation prompts and error messages
preserve meaning and punctuation so the UI logic (confirmation equality checks)
continues to work with the translated strings.
- Around line 7-10: Update the Japanese separator mappings so values use
Japanese punctuation instead of English commas: change the value for the key ","
from ", " to "、"; change the value for the key "、" from ", " to "、"; change the
value for the key ",and " from ", and " to "、および " (matching the existing "、および"
mapping for ", and"); keep the existing ", and": "、および" mapping as-is so all
separators are consistently localized.

In `@web/default/src/i18n/locales/ru.json`:
- Around line 799-801: The JSON contains English strings for compliance/legal
confirmations that must be localized; replace the values for the keys
"Compliance confirmation required", "Compliance confirmed", and "Compliance
confirmed successfully" in ru.json with their correct Russian translations (and
likewise update the other listed keys/strings at the ranges referenced by the
reviewer) ensuring the keys remain unchanged and only the right-hand side values
are translated into Russian so the user-facing confirmation text is fully
localized.

In `@web/default/src/i18n/locales/vi.json`:
- Line 9: The Vietnamese locale currently maps the key ",and " to the English
string ", and "; update the value to the Vietnamese connector ", và " to
localize the UI consistently (replace the value for the ",and " key with ", và
"), matching adjacent connector usage in the vi.json locale.
- Around line 799-801: Replace the English placeholder values in vi.json for the
compliance/legal keys with accurate Vietnamese translations: update the values
for "Compliance confirmation required", "Compliance confirmed", "Compliance
confirmed successfully" (and the other flagged keys at lines referenced: e.g.,
the pairs around 869-891, 1575, 1988-2001, 2640, 2872, 3194-3205, 3744, 3900,
4442-4451) by substituting Vietnamese text while keeping the JSON keys unchanged
and preserving punctuation and sentence meaning; ensure translations are
concise, legally clear, and reviewed for correctness (or sourced from a
native/industry translator) so the consent flows display proper Vietnamese
strings.

In `@web/default/src/i18n/locales/zh.json`:
- Line 1779: The locale key contains an escaped segment
("footer.new\u0061pi.projectAttributionSuffix" -> effective key
"footer.newapi.projectAttributionSuffix") which will not match code that expects
"footer.newApi.projectAttributionSuffix"; update the JSON key to the correct,
consistent key name used by the code (e.g.,
"footer.newApi.projectAttributionSuffix") so the translation resolves, ensuring
the change is made for the "footer.newApi.projectAttributionSuffix" entry and
any other occurrences of the escaped form are normalized.

---

Nitpick comments:
In `@web/default/src/components/layout/components/chat-presets-item.tsx`:
- Around line 100-102: In the ChatPresetsItem component, the span that renders
{preset.name} should include a title attribute so truncated external preset
names are readable on hover; update the span in chat-presets-item.tsx (the
element with className 'min-w-0 flex-1 truncate whitespace-nowrap') to add
title={preset.name} and optionally remove the redundant 'whitespace-nowrap'
class since 'truncate' already applies nowrap.
- Around line 82-84: Add a title attribute to the span that displays the preset
name so truncated names are readable on hover (use the same value as
preset.name); update the element in chat-presets-item.tsx where preset.name is
rendered (the span with class 'min-w-0 flex-1 truncate') to include
title={preset.name}. Also remove the redundant 'whitespace-nowrap' class from
that span since the 'truncate' utility already applies nowrap.

In `@web/default/src/i18n/locales/en.json`:
- Around line 799-801: The JSON uses sentence strings as translation keys;
rename the three keys "Compliance confirmation required", "Compliance
confirmed", and "Compliance confirmed successfully" to hierarchical semantic
keys (for example compliance.confirmation.required, compliance.confirmed,
compliance.confirmed.success), move the original English strings to the values,
and update all code references to use the new keys; also scan and convert the
other sentence-like keys mentioned in your comment to consistent hierarchical
keys (e.g., module.submodule.descriptiveName) and update their usages across the
codebase so keys remain semantic and refactor-safe.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c2c62a28-c6da-4cd5-92b8-557ea874cb3f

📥 Commits

Reviewing files that changed from the base of the PR and between 18282e6 and 823f70d.

📒 Files selected for processing (22)
  • makefile
  • web/default/src/components/language-switcher.tsx
  • web/default/src/components/layout/components/chat-presets-item.tsx
  • web/default/src/components/ui/form.tsx
  • web/default/src/features/channels/components/dialogs/channel-test-dialog.tsx
  • web/default/src/features/channels/components/dialogs/multi-key-manage-dialog.tsx
  • web/default/src/features/channels/components/drawers/channel-mutate-drawer.tsx
  • web/default/src/features/profile/components/language-preferences-card.tsx
  • web/default/src/features/system-settings/content/dashboard-section.tsx
  • web/default/src/i18n/languages.ts
  • web/default/src/i18n/locales/_reports/_sync-report.json
  • web/default/src/i18n/locales/_reports/fr.untranslated.json
  • web/default/src/i18n/locales/_reports/ja.untranslated.json
  • web/default/src/i18n/locales/_reports/ru.untranslated.json
  • web/default/src/i18n/locales/_reports/vi.untranslated.json
  • web/default/src/i18n/locales/en.json
  • web/default/src/i18n/locales/fr.json
  • web/default/src/i18n/locales/ja.json
  • web/default/src/i18n/locales/ru.json
  • web/default/src/i18n/locales/vi.json
  • web/default/src/i18n/locales/zh.json
  • web/default/src/i18n/static-keys.ts

Comment thread makefile
Comment on lines +49 to +64
@if docker compose -f $(DEV_COMPOSE_FILE) ps --services --status running | grep -qx "$(DEV_POSTGRES_SERVICE)"; then \
echo "Detected running docker dev PostgreSQL. Removing setup record and root users..."; \
docker compose -f $(DEV_COMPOSE_FILE) exec -T $(DEV_POSTGRES_SERVICE) \
psql -U $(DEV_POSTGRES_USER) -d $(DEV_POSTGRES_DB) \
-c 'DELETE FROM setups;' \
-c 'DELETE FROM users WHERE role = 100;' \
-c "DELETE FROM options WHERE key IN ('SelfUseModeEnabled', 'DemoSiteEnabled');"; \
echo "Restarting docker dev backend so setup status is recalculated..."; \
docker compose -f $(DEV_COMPOSE_FILE) restart $(DEV_BACKEND_SERVICE); \
elif db_path="$${SQLITE_PATH:-$(DEV_SQLITE_PATH)}"; db_path="$${db_path%%\?*}"; [ -f "$$db_path" ]; then \
db_path="$${SQLITE_PATH:-$(DEV_SQLITE_PATH)}"; \
db_path="$${db_path%%\?*}"; \
echo "Detected local SQLite database: $$db_path"; \
sqlite3 "$$db_path" \
"DELETE FROM setups; DELETE FROM users WHERE role = 100; DELETE FROM options WHERE key IN ('SelfUseModeEnabled', 'DemoSiteEnabled');"; \
echo "SQLite setup state reset. Restart the local backend process before testing the setup wizard."; \
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 | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -eu

python - <<'PY'
from pathlib import Path

lines = Path("makefile").read_text().splitlines()
start = next(i for i, line in enumerate(lines, 1) if line.startswith("reset-setup:"))
end = len(lines) + 1
for i in range(start + 1, len(lines) + 1):
    line = lines[i - 1]
    if line and not line.startswith("\t"):
        end = i
        break

block = lines[start - 1:end - 1]
for i, line in enumerate(block, start):
    print(f"{i}:{line}")

print("\nHas fail-fast guard:", any("set -e" in line for line in block))
print("Has Postgres transaction:", any("BEGIN;" in line and "psql" not in line for line in block))
print("Has SQLite transaction:", any('sqlite3 "$$db_path"' in line for line in block) and any("BEGIN;" in line and "sqlite3" not in line for line in block))
PY

Repository: QuantumNous/new-api

Length of output: 1671


Add fail-fast and transaction wrappers to prevent silent failures.

The reset-setup target lacks a fail-fast guard (set -e) and transactional wrappers around database operations. If psql or sqlite3 fails, the subsequent echo and restart commands still execute, causing the target to exit 0 even though the setup state was not cleared. Wrap both database branches with transaction commands and add a fail-fast guard at the start.

Suggested fix
 reset-setup:
 	`@echo` "Resetting local setup wizard state..."
-	`@if` docker compose -f $(DEV_COMPOSE_FILE) ps --services --status running | grep -qx "$(DEV_POSTGRES_SERVICE)"; then \
+	`@set` -e; \
+	if docker compose -f $(DEV_COMPOSE_FILE) ps --services --status running | grep -qx "$(DEV_POSTGRES_SERVICE)"; then \
 		echo "Detected running docker dev PostgreSQL. Removing setup record and root users..."; \
 		docker compose -f $(DEV_COMPOSE_FILE) exec -T $(DEV_POSTGRES_SERVICE) \
-			psql -U $(DEV_POSTGRES_USER) -d $(DEV_POSTGRES_DB) \
-			-c 'DELETE FROM setups;' \
-			-c 'DELETE FROM users WHERE role = 100;' \
-			-c "DELETE FROM options WHERE key IN ('SelfUseModeEnabled', 'DemoSiteEnabled');"; \
+			psql -v ON_ERROR_STOP=1 -U $(DEV_POSTGRES_USER) -d $(DEV_POSTGRES_DB) \
+			-c 'BEGIN;' \
+			-c 'DELETE FROM setups;' \
+			-c 'DELETE FROM users WHERE role = 100;' \
+			-c "DELETE FROM options WHERE key IN ('SelfUseModeEnabled', 'DemoSiteEnabled');" \
+			-c 'COMMIT;'; \
 		echo "Restarting docker dev backend so setup status is recalculated..."; \
 		docker compose -f $(DEV_COMPOSE_FILE) restart $(DEV_BACKEND_SERVICE); \
 	elif db_path="$${SQLITE_PATH:-$(DEV_SQLITE_PATH)}"; db_path="$${db_path%%\?*}"; [ -f "$$db_path" ]; then \
 		db_path="$${SQLITE_PATH:-$(DEV_SQLITE_PATH)}"; \
 		db_path="$${db_path%%\?*}"; \
 		echo "Detected local SQLite database: $$db_path"; \
 		sqlite3 "$$db_path" \
-			"DELETE FROM setups; DELETE FROM users WHERE role = 100; DELETE FROM options WHERE key IN ('SelfUseModeEnabled', 'DemoSiteEnabled');"; \
+			"BEGIN; DELETE FROM setups; DELETE FROM users WHERE role = 100; DELETE FROM options WHERE key IN ('SelfUseModeEnabled', 'DemoSiteEnabled'); COMMIT;"; \
 		echo "SQLite setup state reset. Restart the local backend process before testing the setup wizard."; \
 	else \
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@makefile` around lines 49 - 64, Add fail-fast and transactional guards to the
reset-setup target: enable shell fail-fast by prefixing the multi-line recipe
branches with "set -e;" and for the Postgres branch call psql with ON_ERROR_STOP
(psql -v ON_ERROR_STOP=1) and wrap the SQL in a transaction (BEGIN; ...;
COMMIT;), and for the SQLite branch wrap the statements in a transaction (BEGIN
TRANSACTION; ...; COMMIT;) so any SQL error aborts and prevents the subsequent
echo/restart steps; locate and modify the Docker/Postgres exec line that invokes
psql and the sqlite3 invocation to include these changes.

"_copy": "_copie",
",": ", ",
", and": ", et",
",and ": ", and ",
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 | ⚡ Quick win

French conjunction mapping appears incorrect.

",and " is mapped to ", and " (English), which can inject English conjunctions in FR output. This should be French (e.g., ", et ").

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/default/src/i18n/locales/fr.json` at line 9, The French locale has the
English conjunction as the value for the key ",and " which will produce English
text in French UI; update the mapping for the JSON key ",and " in fr.json to the
correct French conjunction value (e.g., ", et "), save the file and re-run any
i18n build/validation so the change propagates (look specifically for the ",and
" entry in fr.json to locate and edit it).

Comment on lines +799 to +801
"Compliance confirmation required": "Compliance confirmation required",
"Compliance confirmed": "Compliance confirmed",
"Compliance confirmed successfully": "Compliance confirmed successfully",
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 | 🏗️ Heavy lift

Critical FR compliance UX strings are still untranslated.

These French-locale values are still English, including legal acknowledgements and compliance-gating messages. Since users must read/confirm these to proceed, this creates a high-risk UX/compliance gap for fr.

Also applies to: 869-878, 891-895, 1575-1575, 1988-1989, 2001-2001, 2640-2640, 2872-2872, 3194-3194, 3205-3205, 3744-3744, 3900-3900, 4442-4451

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/default/src/i18n/locales/fr.json` around lines 799 - 801, The French
locale contains untranslated UX/compliance strings; locate the keys "Compliance
confirmation required", "Compliance confirmed", and "Compliance confirmed
successfully" (and the other untranslated keys noted around lines 869-878,
891-895, 1575, 1988-1989, 2001, 2640, 2872, 3194, 3205, 3744, 3900, and
4442-4451) in web/default/src/i18n/locales/fr.json and replace the English
values with accurate French translations that preserve tone and legal meaning;
ensure pluralization/variables (if any) remain intact and run the localization
linter/CI to validate JSON and coverage after updating all affected keys.

Comment on lines +7 to +10
",": ", ",
", and": "、および",
",and ": ", and ",
"、": ", ",
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 | ⚡ Quick win

Keep the Japanese separator mappings localized.

These values now normalize and back to English comma formatting, so otherwise Japanese UI copy will render with mixed punctuation. Please keep these separator entries aligned with the Japanese separators already used elsewhere in this locale.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/default/src/i18n/locales/ja.json` around lines 7 - 10, Update the
Japanese separator mappings so values use Japanese punctuation instead of
English commas: change the value for the key "," from ", " to "、"; change the
value for the key "、" from ", " to "、"; change the value for the key ",and "
from ", and " to "、および " (matching the existing "、および" mapping for ", and");
keep the existing ", and": "、および" mapping as-is so all separators are
consistently localized.

"Account ID *": "アカウントID *",
"Account Info": "アカウント情報",
"Account used when authenticating with the SMTP server": "SMTPサーバーで認証する際に使用されるアカウント",
"acknowledge the related legal risks": "acknowledge the related legal risks",
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 | ⚡ Quick win

Translate the new compliance flow copy in the Japanese locale.

These entries are still English in ja.json. Because they drive the payment/compliance gating flow, Japanese users will see mixed-language legal text, errors, and exact-match confirmation prompts, which undermines comprehension and can block completion.

Also applies to: 799-801, 869-869, 877-895, 1575-1575, 1988-2002, 2640-2640, 2872-2872, 2966-2966, 3194-3205, 3744-3744, 3868-3868, 3900-3900, 4102-4102, 4442-4451

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/default/src/i18n/locales/ja.json` at line 123, The Japanese locale
contains untranslated English keys (e.g., the string "acknowledge the related
legal risks" in ja.json) used in the compliance/payment gating flow; replace
these English values with accurate Japanese translations for all listed
occurrences (including ranges 799-801, 869, 877-895, 1575, 1988-2002, 2640,
2872, 2966, 3194-3205, 3744, 3868, 3900, 4102, 4442-4451) and ensure any
exact-match confirmation prompts and error messages preserve meaning and
punctuation so the UI logic (confirmation equality checks) continues to work
with the translated strings.

Comment on lines +799 to +801
"Compliance confirmation required": "Compliance confirmation required",
"Compliance confirmed": "Compliance confirmed",
"Compliance confirmed successfully": "Compliance confirmed successfully",
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 | 🏗️ Heavy lift

Localize compliance/legal consent strings in ru.json before release.

These user-facing compliance confirmations and legal-responsibility statements are still English in the Russian locale. In this flow, that creates a real comprehension risk for gated actions (payment/subscription/redemption/invitation) and undermines informed confirmation.

Also applies to: 869-878, 891-895, 1575-1575, 1988-1990, 2001-2001, 2640-2640, 2872-2872, 3194-3194, 3205-3205, 3744-3744, 3900-3900, 4102-4102, 4442-4451

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/default/src/i18n/locales/ru.json` around lines 799 - 801, The JSON
contains English strings for compliance/legal confirmations that must be
localized; replace the values for the keys "Compliance confirmation required",
"Compliance confirmed", and "Compliance confirmed successfully" in ru.json with
their correct Russian translations (and likewise update the other listed
keys/strings at the ranges referenced by the reviewer) ensuring the keys remain
unchanged and only the right-hand side values are translated into Russian so the
user-facing confirmation text is fully localized.

"_copy": "_bản sao",
",": ", ",
", and": ", và",
",and ": ", and ",
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 | ⚡ Quick win

Fix English connector in Vietnamese locale value

Line 9 maps ",and " to ", and ", which keeps English output in Vietnamese UI. This should be localized consistently (e.g., ", và "), aligned with the adjacent connector key usage.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/default/src/i18n/locales/vi.json` at line 9, The Vietnamese locale
currently maps the key ",and " to the English string ", and "; update the value
to the Vietnamese connector ", và " to localize the UI consistently (replace the
value for the ",and " key with ", và "), matching adjacent connector usage in
the vi.json locale.

Comment on lines +799 to +801
"Compliance confirmation required": "Compliance confirmation required",
"Compliance confirmed": "Compliance confirmed",
"Compliance confirmed successfully": "Compliance confirmed successfully",
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 | 🏗️ Heavy lift

Translate compliance/legal Vietnamese strings instead of shipping English fallbacks

Several newly added compliance and legal confirmation texts are still English in vi.json (for example Line 799, Line 877, Line 1988, Line 2872, Line 4442). This can break consent/comprehension flows for Vietnamese users and weakens legal acknowledgment UX.

Please provide actual Vietnamese translations for these keys before release.

Also applies to: 869-870, 877-878, 891-891, 895-895, 1575-1575, 1988-1989, 2001-2001, 2640-2640, 2872-2872, 3194-3194, 3205-3205, 3744-3744, 3900-3900, 4442-4451

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/default/src/i18n/locales/vi.json` around lines 799 - 801, Replace the
English placeholder values in vi.json for the compliance/legal keys with
accurate Vietnamese translations: update the values for "Compliance confirmation
required", "Compliance confirmed", "Compliance confirmed successfully" (and the
other flagged keys at lines referenced: e.g., the pairs around 869-891, 1575,
1988-2001, 2640, 2872, 3194-3205, 3744, 3900, 4442-4451) by substituting
Vietnamese text while keeping the JSON keys unchanged and preserving punctuation
and sentence meaning; ensure translations are concise, legally clear, and
reviewed for correctness (or sourced from a native/industry translator) so the
consent flows display proper Vietnamese strings.

"footer.columns.related.title": "相关项目",
"footer.defaultCopyright": "版权所有。",
"footer.newapi.projectAttributionSuffix": "版权所有,由项目贡献者设计与开发。",
"footer.new\u0061pi.projectAttributionSuffix": "版权所有,由项目贡献者设计与开发。",
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 | ⚡ Quick win

Potential i18n key mismatch caused by escaped key segment

Line 1779 uses footer.new\u0061pi.projectAttributionSuffix (effective key: footer.newapi.projectAttributionSuffix). If code references footer.newApi.projectAttributionSuffix, this translation will never resolve.

Suggested fix
-    "footer.new\u0061pi.projectAttributionSuffix": "版权所有,由项目贡献者设计与开发。",
+    "footer.newApi.projectAttributionSuffix": "版权所有,由项目贡献者设计与开发。",

As per coding guidelines, "Use hierarchical and semantically clear translation key names such as dashboard.overview.title and maintain naming consistency".

📝 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
"footer.new\u0061pi.projectAttributionSuffix": "版权所有,由项目贡献者设计与开发。",
"footer.newApi.projectAttributionSuffix": "版权所有,由项目贡献者设计与开发。",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/default/src/i18n/locales/zh.json` at line 1779, The locale key contains
an escaped segment ("footer.new\u0061pi.projectAttributionSuffix" -> effective
key "footer.newapi.projectAttributionSuffix") which will not match code that
expects "footer.newApi.projectAttributionSuffix"; update the JSON key to the
correct, consistent key name used by the code (e.g.,
"footer.newApi.projectAttributionSuffix") so the translation resolves, ensuring
the change is made for the "footer.newApi.projectAttributionSuffix" entry and
any other occurrences of the escaped form are normalized.

@Calcium-Ion Calcium-Ion merged commit f69ceb6 into main May 17, 2026
2 checks passed
chenglu added a commit to chenglu/new-api that referenced this pull request May 17, 2026
Merged 28 commits from QuantumNous/new-api upstream/main, including:

Backend:
- feat: support request_header key source (QuantumNous#4903)
- fix: apply group filter to channel list queries (QuantumNous#4885, QuantumNous#4847)
- fix: enforce header nav access control for public modules (QuantumNous#4889)
- fix: correct usage logs filtering (QuantumNous#4883)
- fix: allow clearing channel remark (QuantumNous#4886)
- feat: track upstream request ID and prevent response header override
- feat: require compliance confirmation for paid features

Frontend:
- fix: 修复新 UI 语言与文案显示问题 (QuantumNous#4876)
- fix(web): handle unlimited API key quota validation (QuantumNous#4881)
- fix(web/default): batch fix new UI issues (QuantumNous#4880, QuantumNous#4893, QuantumNous#4817, QuantumNous#4877, QuantumNous#4898)
- fix: prevent combobox from over-filtering options on focus (QuantumNous#4829)
- fix(default): support DropdownMenuItem onSelect (QuantumNous#4787)
- chore(deps): bump axios to 1.15.2

Conflict resolution:
- Locale JSONs: union merge (design overrides preserved, upstream new keys added)
- router/api-router.go: kept design /public/session route, accepted upstream HeaderNavModuleAuth
- common-logs-filter-bar.tsx: kept design refactor, added upstream upstreamRequestId field
- summary-cards.tsx: kept design layout, adapted to new useSummaryCardsConfig interface
- _reports/*.untranslated.json: design state kept (fr/vi removed, ja/ru ours)
- Other UI conflicts resolved per .gitattributes ours strategy

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

2 participants