diff --git a/astro.config.mjs b/astro.config.mjs
index 9fbc5f0..83ad662 100644
--- a/astro.config.mjs
+++ b/astro.config.mjs
@@ -16,6 +16,7 @@ export default defineConfig({
starlight({
title: 'Xahau Docs',
description: 'Documentation for the Xahau blockchain',
+ defaultLocale: 'root',
locales: {
root: { label: 'English', lang: 'en' },
es: { label: 'Español', lang: 'es' },
diff --git a/src/components/Footer.astro b/src/components/Footer.astro
index 479381d..f34550c 100644
--- a/src/components/Footer.astro
+++ b/src/components/Footer.astro
@@ -1,11 +1,9 @@
---
import { Image } from 'astro:assets'
+ import { getRelativeLocaleUrl } from 'astro:i18n'
import logo from '../assets/xahau-logo.svg'
- const LOCALES = ['es', 'ja']
- const firstSegment = Astro.url.pathname.split('/')[1]
- const locale = LOCALES.includes(firstSegment) ? firstSegment : 'en'
- const p = locale !== 'en' ? `/${locale}` : ''
+ const locale = Astro.currentLocale ?? 'en'
const translations = {
en: {
@@ -78,7 +76,7 @@
class="flex-none container mx-auto py-12 max-w-7xl p-6 grid grid-cols-1 md:grid-cols-10 gap-4"
>
diff --git a/src/components/Header.jsx b/src/components/Header.jsx
index c8aed53..ce73576 100644
--- a/src/components/Header.jsx
+++ b/src/components/Header.jsx
@@ -21,7 +21,6 @@ import { useState } from 'react'
import logo from '../assets/xahau-logo.svg'
-const LOCALES = ['es', 'ja']
const languages = [
{ code: 'en', label: 'English', flag: '🇬🇧' },
@@ -85,8 +84,7 @@ export default function Header(props) {
const [mobileMenuOpen, setMobileMenuOpen] = useState(false)
const pathname = props.url.pathname
- const firstSegment = pathname.split('/')[1]
- const currentLocale = LOCALES.includes(firstSegment) ? firstSegment : 'en'
+ const currentLocale = props.locale || 'en'
const p = currentLocale !== 'en' ? `/${currentLocale}` : ''
const t = nav[currentLocale]
@@ -132,7 +130,7 @@ export default function Header(props) {
]
const pathSegments = pathname.slice(1).split('/')
- const activeSegment = LOCALES.includes(pathSegments[0])
+ const activeSegment = currentLocale !== 'en'
? pathSegments[1]
: pathSegments[0]
diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro
index a5a256f..51cdbfc 100644
--- a/src/layouts/BaseLayout.astro
+++ b/src/layouts/BaseLayout.astro
@@ -3,8 +3,7 @@
import Footer from '../components/Footer.astro'
import Header from '../components/Header.jsx'
- const _firstSeg = Astro.url.pathname.split('/')[1]
- const _lang = ['es', 'ja'].includes(_firstSeg) ? _firstSeg : 'en'
+ const _lang = Astro.currentLocale ?? 'en'
const _canonicalURL = new URL(Astro.url.pathname, Astro.site)
const _socialImageURL = new URL('/xahau-logo.png', Astro.site)
const _title = Astro.props.frontmatter?.title
@@ -41,7 +40,7 @@
-
+
diff --git a/src/layouts/DocsLayout.astro b/src/layouts/DocsLayout.astro
index 1f8cd0f..7fabb8f 100644
--- a/src/layouts/DocsLayout.astro
+++ b/src/layouts/DocsLayout.astro
@@ -12,7 +12,7 @@
rel="stylesheet"
>
-
+
diff --git a/src/layouts/IndexLayout.astro b/src/layouts/IndexLayout.astro
index b78a072..ffc8d24 100644
--- a/src/layouts/IndexLayout.astro
+++ b/src/layouts/IndexLayout.astro
@@ -1,5 +1,6 @@
---
import '../styles/main.css'
+ import { getRelativeLocaleUrl } from 'astro:i18n'
import worldmap from '../assets/worldmap.svg'
import type { IndexLocale } from '../i18n/indexTranslations'
import { indexTranslations } from '../i18n/indexTranslations'
@@ -7,12 +8,7 @@
const _frontmatter = Astro.props.frontmatter
- const LOCALES = ['es', 'ja']
- const firstSegment = Astro.url.pathname.split('/')[1]
- const locale = (
- LOCALES.includes(firstSegment) ? firstSegment : 'en'
- ) as IndexLocale
- const p = locale !== 'en' ? `/${locale}` : ''
+ const locale = (Astro.currentLocale ?? 'en') as IndexLocale
const i = indexTranslations[locale]
---
@@ -42,13 +38,13 @@
{i.feat_more}
+ {i.feat_more}
+
@@ -144,7 +141,7 @@
{i.stats_node_cta}