[PR #6960] [MERGED] fix(routing): show the Balancer label on mobile rule cards #6544

Closed
opened 2026-11-02 04:09:31 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6960
Author: @eric15342335
Created: 10/26/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @MHSanaei

Base: main ← Head: claude/3x-ui-xray-balancer-i18n-cb0660


📝 Commits (1)

  • f33608b fix(routing): show the Balancer label on mobile rule cards

📊 Changes

2 files changed (+13 additions, -4 deletions)

View changed files

📝 frontend/src/pages/xray/routing/RuleCardList.tsx (+1 -3)
📝 frontend/src/test/i18n-dead-keys.test.ts (+12 -1)

📄 Description

Summary

In windows 768 px wide or narrower, which includes phones, a routing rule that targets a balancer showed key 'pages.xray.balancer (en-US)' returned an object instead of string. on its card in Xray Configs → Routing. The card now shows the translated "Balancer" label.

Why

RuleCardList.tsx labelled those rules with t('pages.xray.balancer') || 'Balancer'. That key is the balancer form's group of keys (.tag, .selector, …), not a string. For a group, i18next returns the "returned an object" message, and since that message is a non-empty string, the || 'Balancer' fallback never ran. It showed in every locale. The desktop table uses a different key and wasn't affected.

The card now uses pages.xray.rules.balancer, the "Balancer" label the Balancers tab already uses. All 14 locales translate it, so no locale files change.

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

  • New test in frontend/src/test/i18n-dead-keys.test.ts: it collects every literal t() key in the frontend and Go sources and fails if one names a group of keys instead of a string. Before the fix it failed and listed only pages.xray.balancer. It passes now.
  • The typecheck, lint, format:check, build and build-storybook scripts pass. The Vitest unit and components projects pass (1920 tests), and so does the Storybook project (99 tests).
  • I ran the official ghcr.io/mhsanaei/3x-ui:v3.11.0 image, added a routing rule that targets a balancer, and opened Xray Configs → Routing in Chromium at 375×812:
    • v3.11.0's own frontend showed the "returned an object" message on the rule's card.
    • This branch's frontend, served by the Vite dev server against the same panel, shows "Balancer". With the fix reverted, the message came back.
    • At 1280 px, the desktop table shows the rule without the message.

Screenshots / recordings

Before:

image

After:

image

Breaking changes

None.

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally. (No Go files changed, and there's no Go toolchain on this machine, so I didn't run them.)
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed. (Not needed for a label fix.)
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6960 **Author:** [@eric15342335](https://github.com/eric15342335) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `claude/3x-ui-xray-balancer-i18n-cb0660` --- ### 📝 Commits (1) - [`f33608b`](https://github.com/MHSanaei/3x-ui/commit/f33608bee4d37f84d7b0eb978ca69198b4f5a4c3) fix(routing): show the Balancer label on mobile rule cards ### 📊 Changes **2 files changed** (+13 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/pages/xray/routing/RuleCardList.tsx` (+1 -3) 📝 `frontend/src/test/i18n-dead-keys.test.ts` (+12 -1) </details> ### 📄 Description ## Summary In windows 768 px wide or narrower, which includes phones, a routing rule that targets a balancer showed `key 'pages.xray.balancer (en-US)' returned an object instead of string.` on its card in Xray Configs → Routing. The card now shows the translated "Balancer" label. ## Why `RuleCardList.tsx` labelled those rules with `t('pages.xray.balancer') || 'Balancer'`. That key is the balancer form's group of keys (`.tag`, `.selector`, …), not a string. For a group, i18next returns the "returned an object" message, and since that message is a non-empty string, the `|| 'Balancer'` fallback never ran. It showed in every locale. The desktop table uses a different key and wasn't affected. The card now uses `pages.xray.rules.balancer`, the "Balancer" label the Balancers tab already uses. All 14 locales translate it, so no locale files change. ## Type of change - [x] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [x] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? - New test in `frontend/src/test/i18n-dead-keys.test.ts`: it collects every literal `t()` key in the frontend and Go sources and fails if one names a group of keys instead of a string. Before the fix it failed and listed only `pages.xray.balancer`. It passes now. - The `typecheck`, `lint`, `format:check`, `build` and `build-storybook` scripts pass. The Vitest unit and components projects pass (1920 tests), and so does the Storybook project (99 tests). - I ran the official `ghcr.io/mhsanaei/3x-ui:v3.11.0` image, added a routing rule that targets a balancer, and opened Xray Configs → Routing in Chromium at 375×812: - v3.11.0's own frontend showed the "returned an object" message on the rule's card. - This branch's frontend, served by the Vite dev server against the same panel, shows "Balancer". With the fix reverted, the message came back. - At 1280 px, the desktop table shows the rule without the message. ## Screenshots / recordings Before: <img width="394" height="852" alt="image" src="https://github.com/user-attachments/assets/9e0ee952-1824-4777-bbad-566d68d446ab" /> After: <img width="394" height="852" alt="image" src="https://github.com/user-attachments/assets/b9eb5f74-68af-4e19-8ff0-c501ee7bdbe7" /> ## Breaking changes None. ## Checklist - [x] I tested the change locally and confirmed the described behavior. - [x] I added or updated tests for the new behavior (when applicable). - [ ] `go build ./...` and the test suite pass locally. (No Go files changed, and there's no Go toolchain on this machine, so I didn't run them.) - [x] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. (Not needed for a label fix.) - [x] My commits follow the project's existing message style. - [x] I have no unrelated changes mixed into this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi changed title from [PR #6960] fix(routing): show the Balancer label on mobile rule cards to [PR #6960] [MERGED] fix(routing): show the Balancer label on mobile rule cards 2026-11-07 14:33:53 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6544
No description provided.