Files
freedakgmail a550d6d0fd feat: Heritage Globe - 中国文物全球分布地图
- Next.js + MapLibre GL 3D 地球
- CARTO dark-matter vector 底图
- 动态星空背景(闪烁、漂移、流星)
- 经纬网格线(graticule)
- 文物数据图层与朝代/类别筛选
- 中国风信息弹窗
- 中英双语 i18n
- LayerPanel + MapControls 浮动面板
2026-07-01 01:37:18 +08:00

29 lines
884 B
TypeScript

'use client';
import { useLocale } from 'next-intl';
import { useRouter, usePathname } from 'next/navigation';
import { Globe } from 'lucide-react';
export function LanguageSwitcher() {
const locale = useLocale();
const router = useRouter();
const pathname = usePathname();
const toggleLanguage = () => {
const newLocale = locale === 'zh' ? 'en' : 'zh';
// 替换 URL 中的语言前缀
const newPath = pathname.replace(`/${locale}`, `/${newLocale}`);
router.push(newPath);
};
return (
<button
onClick={toggleLanguage}
className="flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-sm font-medium text-[var(--map-text-muted)] hover:text-white hover:bg-white/10 transition-colors"
aria-label="Switch language"
>
<Globe className="w-4 h-4" />
<span>{locale === 'zh' ? 'EN' : '中文'}</span>
</button>
);
}