fix: locale toggle shows current language, date inputs respect locale

- Language switcher now displays current locale (中文/English) instead of target
- Add lang attribute to date inputs for proper localization of native date picker
This commit is contained in:
2026-04-07 15:30:25 +08:00
parent c45e026ab3
commit 918a615793
2 changed files with 4 additions and 2 deletions

View File

@@ -101,7 +101,7 @@ export function Sidebar() {
style={{ color: "var(--text-muted)", background: "var(--row-hover)", border: "1px solid var(--surface-border)" }}
>
<Languages className="h-3.5 w-3.5" />
<span className="font-medium">{locale === "zh" ? "English" : "中文"}</span>
<span className="font-medium">{locale === "zh" ? "中文" : "English"}</span>
</button>
{/* Status */}

View File

@@ -8,7 +8,7 @@ import { useTimeRange } from "@/lib/time-range-context";
import { useI18n } from "@/lib/i18n";
export function TimeRangeSelector() {
const { t } = useI18n();
const { t, locale } = useI18n();
const { range, setRange, customStart, customEnd, setCustomStart, setCustomEnd } = useTimeRange();
const [showPopover, setShowPopover] = useState(false);
const [localStart, setLocalStart] = useState(customStart);
@@ -126,6 +126,7 @@ export function TimeRangeSelector() {
</label>
<input
type="date"
lang={locale === "zh" ? "zh-CN" : "en-US"}
value={localStart}
onChange={(e) => setLocalStart(e.target.value)}
className="input-glass w-full rounded-md px-3 py-1.5 text-xs font-[family-name:var(--font-geist-mono)]"
@@ -137,6 +138,7 @@ export function TimeRangeSelector() {
</label>
<input
type="date"
lang={locale === "zh" ? "zh-CN" : "en-US"}
value={localEnd}
onChange={(e) => setLocalEnd(e.target.value)}
className="input-glass w-full rounded-md px-3 py-1.5 text-xs font-[family-name:var(--font-geist-mono)]"