mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-02 19:25:05 +03:00
fix(routing): show the Balancer label on mobile rule cards (#6960)
RuleCardList labelled balancer rules with t('pages.xray.balancer'), which is an object in every locale, so phones showed i18next's 'returned an object instead of string' error. It now uses the pages.xray.rules.balancer leaf the Balancers tab already uses, and the dead-keys test fails on any literal key that names a group.
This commit is contained in:
committed by
GitHub
parent
14f2bb5e2c
commit
05199dda00
@@ -152,9 +152,7 @@ export default function RuleCardList({
|
||||
<span className="flow-arrow">→</span>
|
||||
<div className="flow-side flow-side-target">
|
||||
<span className="flow-label">
|
||||
{rule.balancerTag
|
||||
? t('pages.xray.balancer') || 'Balancer'
|
||||
: t('pages.xray.Outbounds')}
|
||||
{rule.balancerTag ? t('pages.xray.rules.balancer') : t('pages.xray.Outbounds')}
|
||||
</span>
|
||||
{rule.outboundTag ? (
|
||||
<Tag color="green" className="flow-tag">
|
||||
|
||||
@@ -5,7 +5,7 @@ import { join, resolve } from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
/*
|
||||
* Guards the 14-locale translation set two ways: every key in en-US must be
|
||||
* Guards the 14-locale translation set: every key in en-US must be
|
||||
* referenced somewhere in the frontend or Go sources (dead keys accumulate
|
||||
* silently — this test deleted over two hundred of them when it was
|
||||
* introduced), and every locale must carry exactly the en-US key set
|
||||
@@ -82,6 +82,17 @@ describe('i18n keys', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('no literal t() key resolves to an object', () => {
|
||||
const objectKeys = Array.from(
|
||||
blob.matchAll(/\bt\(\s*(['"`])([\w.-]+)\1\s*[,)]/g),
|
||||
(m) => m[2],
|
||||
).filter((key) => enKeys.some((leaf) => leaf.startsWith(`${key}.`)));
|
||||
expect(
|
||||
objectKeys,
|
||||
`t() keys naming a group, rendered as "key '…' returned an object instead of string.":\n ${objectKeys.join('\n ')}`,
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it('every locale carries exactly the en-US key set', () => {
|
||||
const enSet = new Set(enKeys);
|
||||
for (const file of readdirSync(translationDir)) {
|
||||
|
||||
Reference in New Issue
Block a user