From 36cbf3e841ec51aeca90d0593e95061893604a5a Mon Sep 17 00:00:00 2001 From: pcodedynamics Date: Tue, 1 Dec 2026 01:54:36 +0700 Subject: [PATCH] fix(i18n): redesign the language switcher --- src/components/layout/Header.astro | 72 +++++++------- src/components/layout/LanguageSwitcher.astro | 98 ++++++++++++++++++++ 2 files changed, 138 insertions(+), 32 deletions(-) create mode 100644 src/components/layout/LanguageSwitcher.astro diff --git a/src/components/layout/Header.astro b/src/components/layout/Header.astro index 89b88be..67851cb 100644 --- a/src/components/layout/Header.astro +++ b/src/components/layout/Header.astro @@ -1,6 +1,7 @@ --- import { localizedDocsHome, localizedLandingPath } from '../../lib/locales'; import type { LanguageAlternates, Locale } from '../../lib/locales'; +import LanguageSwitcher from './LanguageSwitcher.astro'; interface Props { locale?: Locale; @@ -11,9 +12,6 @@ const { locale = 'vi', languageAlternates } = Astro.props; const english = locale === 'en'; const isBlog = Astro.url.pathname.startsWith('/blog'); const home = localizedLandingPath(locale); -const alternateLocale = english ? 'vi' : 'en'; -const alternatePath = languageAlternates?.[alternateLocale]; -const alternateLabel = english ? 'Tiếng Việt' : 'English'; const navigation = [ { href: `${home}#experience`, label: english ? 'Explore' : 'Khám phá' }, { href: `${home}#platforms`, label: english ? 'Platforms' : 'Nền tảng' }, @@ -42,10 +40,10 @@ const navigation = [ ))}