fix(quota): translate Codex window labels at render time

This commit is contained in:
LTbinglingfeng
2026-01-02 00:41:35 +08:00
parent 7ce97a616f
commit 079f37ec93
2 changed files with 10 additions and 6 deletions

View File

@@ -1031,7 +1031,7 @@ export function QuotaPage() {
const windows: CodexQuotaWindow[] = []; const windows: CodexQuotaWindow[] = [];
const addWindow = ( const addWindow = (
id: string, id: string,
label: string, labelKey: string,
window?: CodexUsageWindow | null, window?: CodexUsageWindow | null,
limitReached?: boolean, limitReached?: boolean,
allowed?: boolean allowed?: boolean
@@ -1044,7 +1044,8 @@ export function QuotaPage() {
usedPercentRaw ?? (isLimitReached && resetLabel !== '-' ? 100 : null); usedPercentRaw ?? (isLimitReached && resetLabel !== '-' ? 100 : null);
windows.push({ windows.push({
id, id,
label, label: t(labelKey),
labelKey,
usedPercent, usedPercent,
resetLabel resetLabel
}); });
@@ -1052,21 +1053,21 @@ export function QuotaPage() {
addWindow( addWindow(
'primary', 'primary',
t('codex_quota.primary_window'), 'codex_quota.primary_window',
rateLimit?.primary_window ?? rateLimit?.primaryWindow, rateLimit?.primary_window ?? rateLimit?.primaryWindow,
rateLimit?.limit_reached ?? rateLimit?.limitReached, rateLimit?.limit_reached ?? rateLimit?.limitReached,
rateLimit?.allowed rateLimit?.allowed
); );
addWindow( addWindow(
'secondary', 'secondary',
t('codex_quota.secondary_window'), 'codex_quota.secondary_window',
rateLimit?.secondary_window ?? rateLimit?.secondaryWindow, rateLimit?.secondary_window ?? rateLimit?.secondaryWindow,
rateLimit?.limit_reached ?? rateLimit?.limitReached, rateLimit?.limit_reached ?? rateLimit?.limitReached,
rateLimit?.allowed rateLimit?.allowed
); );
addWindow( addWindow(
'code-review', 'code-review',
t('codex_quota.code_review_window'), 'codex_quota.code_review_window',
codeReviewLimit?.primary_window ?? codeReviewLimit?.primaryWindow, codeReviewLimit?.primary_window ?? codeReviewLimit?.primaryWindow,
codeReviewLimit?.limit_reached ?? codeReviewLimit?.limitReached, codeReviewLimit?.limit_reached ?? codeReviewLimit?.limitReached,
codeReviewLimit?.allowed codeReviewLimit?.allowed
@@ -1552,10 +1553,12 @@ export function QuotaPage() {
? styles.quotaBarFillMedium ? styles.quotaBarFillMedium
: styles.quotaBarFillLow; : styles.quotaBarFillLow;
const windowLabel = window.labelKey ? t(window.labelKey) : window.label;
return ( return (
<div key={window.id} className={styles.quotaRow}> <div key={window.id} className={styles.quotaRow}>
<div className={styles.quotaRowHeader}> <div className={styles.quotaRowHeader}>
<span className={styles.quotaModel}>{window.label}</span> <span className={styles.quotaModel}>{windowLabel}</span>
<div className={styles.quotaMeta}> <div className={styles.quotaMeta}>
<span className={styles.quotaPercent}>{percentLabel}</span> <span className={styles.quotaPercent}>{percentLabel}</span>
<span className={styles.quotaReset}>{window.resetLabel}</span> <span className={styles.quotaReset}>{window.resetLabel}</span>

View File

@@ -37,6 +37,7 @@ export interface GeminiCliQuotaState {
export interface CodexQuotaWindow { export interface CodexQuotaWindow {
id: string; id: string;
label: string; label: string;
labelKey?: string;
usedPercent: number | null; usedPercent: number | null;
resetLabel: string; resetLabel: string;
} }