From 0dcebe39d0ec0de8fb20ac7816fa35f8618dca0e Mon Sep 17 00:00:00 2001 From: tequ Date: Tue, 21 Apr 2026 01:51:03 +0900 Subject: [PATCH] refactor: centralize locale definitions into i18n/locales.ts --- src/components/CookieConsent.astro | 3 +- src/components/Footer.astro | 6 +- src/components/XahauConnect.astro | 4 +- src/components/XahauEcosystem.astro | 4 +- src/components/XahauHome.astro | 4 +- src/i18n/fraudReportTranslations.ts | 608 +++++++++++++------------- src/i18n/indexTranslations.ts | 2 - src/i18n/locales.ts | 7 + src/layouts/BaseLayout.astro | 3 +- src/layouts/DocsLayout.astro | 7 +- src/layouts/IndexLayout.astro | 4 +- src/plugins/remarkGlobalReferences.ts | 5 +- src/utils/localizedHref.ts | 3 +- 13 files changed, 336 insertions(+), 324 deletions(-) create mode 100644 src/i18n/locales.ts diff --git a/src/components/CookieConsent.astro b/src/components/CookieConsent.astro index b2aa076..d2d396a 100644 --- a/src/components/CookieConsent.astro +++ b/src/components/CookieConsent.astro @@ -1,8 +1,9 @@ --- import 'vanilla-cookieconsent/dist/cookieconsent.css' import { createCookieConsentConfig } from '../CookieConsentConfig' +import { defaultLocale, type Locale } from '../i18n/locales' -const locale = (Astro.currentLocale ?? 'en') as 'en' | 'es' | 'ja' +const locale = (Astro.currentLocale ?? defaultLocale) as Locale const cookieConsentConfig = createCookieConsentConfig(locale) --- diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 48a97e5..374093c 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -2,8 +2,9 @@ import { Image } from 'astro:assets' import { getRelativeLocaleUrl } from 'astro:i18n' import logo from '../assets/xahau-logo.svg' +import { defaultLocale, type Locale } from '../i18n/locales' -const locale = Astro.currentLocale ?? 'en' +const locale = Astro.currentLocale ?? defaultLocale const translations = { en: { @@ -68,8 +69,7 @@ const translations = { }, } -type Locale = 'en' | 'es' | 'ja' -const t = translations[locale as Locale] || translations.en +const t = translations[locale as Locale] || translations[defaultLocale] ---