--- /** * Language switcher component. * Provides a link to the alternate language version of the current page. */ import { getAltLang } from '@i18n/utils'; interface Props { lang?: 'zh' | 'en'; currentPath?: string; } const { lang = 'zh', currentPath = '/' } = Astro.props; const altLang = getAltLang(lang); // Build the alternate language path by replacing the language prefix const pathParts = currentPath.split('/').filter(Boolean); // Remove current lang prefix if present if (pathParts[0] === lang) { pathParts.shift(); } const altPath = `/${altLang}/${pathParts.join('/')}`; --- {lang === 'zh' ? 'EN' : '中文'}