Files
gitlab-instance-0a899031_cn…/app/components/SetLangAttr.tsx
2026-03-09 05:07:59 -05:00

18 lines
389 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { useEffect } from "react";
import { useLocale } from "@/i18n/navigation";
/**
* 根据当前 locale 设置 document.documentElement.lang以支持无障碍与 SEO
*/
export default function SetLangAttr() {
const locale = useLocale();
useEffect(() => {
document.documentElement.lang = locale === "zh" ? "zh-CN" : "en";
}, [locale]);
return null;
}