From ee33a43ac895ec251662dbf52398e8d86e97d938 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Thu, 19 Dec 2024 00:23:46 +0800 Subject: [PATCH] :globe_with_meridians: Basic i18n setup --- astro.config.mjs | 12 +- src/layouts/Layout.astro | 24 +++- src/pages/en/index.astro | 110 ++++++++++++++++++ src/pages/{ => en}/posts/[...slug].astro | 6 +- .../{ => en}/products/solar-network.astro | 2 +- src/pages/{ => en}/terms/index.astro | 6 +- src/pages/{ => en}/terms/privacy-policy.astro | 2 +- .../{ => en}/terms/user-agreements.astro | 2 +- src/pages/index.astro | 107 +---------------- src/pages/zh-cn/terms/index.astro | 39 +++++++ src/pages/zh-cn/terms/privacy-policy.astro | 49 ++++++++ src/pages/zh-cn/terms/user-agreements.astro | 100 ++++++++++++++++ tsconfig.json | 16 ++- 13 files changed, 357 insertions(+), 118 deletions(-) create mode 100644 src/pages/en/index.astro rename src/pages/{ => en}/posts/[...slug].astro (93%) rename src/pages/{ => en}/products/solar-network.astro (99%) rename src/pages/{ => en}/terms/index.astro (93%) rename src/pages/{ => en}/terms/privacy-policy.astro (97%) rename src/pages/{ => en}/terms/user-agreements.astro (99%) create mode 100644 src/pages/zh-cn/terms/index.astro create mode 100644 src/pages/zh-cn/terms/privacy-policy.astro create mode 100644 src/pages/zh-cn/terms/user-agreements.astro diff --git a/astro.config.mjs b/astro.config.mjs index a840024..ab9992e 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -5,10 +5,18 @@ import tailwind from '@astrojs/tailwind' import icon from 'astro-icon' -import mdx from '@astrojs/mdx'; +import mdx from '@astrojs/mdx' // https://astro.build/config export default defineConfig({ integrations: [tailwind(), icon(), mdx()], prefetch: true, -}) \ No newline at end of file + i18n: { + locales: ['en', 'zh-cn'], + defaultLocale: 'en', + routing: { + fallbackType: 'rewrite', + prefixDefaultLocale: true, + }, + }, +}) diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index c02ea40..f95c18c 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -1,19 +1,24 @@ --- +export const prerender = false + import { Image } from 'astro:assets' import { version } from '../../package.json' import CompanyLogo from '../assets/images/company-logo.png' +import { getRelativeLocaleUrl } from 'astro:i18n' interface Props { title?: string } const { title } = Astro.props + +const locale = Astro.currentLocale ?? 'en' --- - + @@ -93,13 +98,24 @@ const { title } = Astro.props diff --git a/src/pages/en/index.astro b/src/pages/en/index.astro new file mode 100644 index 0000000..27a588d --- /dev/null +++ b/src/pages/en/index.astro @@ -0,0 +1,110 @@ +--- +import { Image } from 'astro:assets' +import { Icon } from 'astro-icon/components' + +import Layout from '@/layouts/Layout.astro' + +import CompanyAsideImage from '@/assets/images/company-aside.webp' +import AppStoreGetImage from '@/assets/images/app-store/get-it-on-black.svg' +import ProductSnPreviewImage from '@/assets/images/products/solar-network.webp' +--- + + +
+
+

Solsynth LLC

+

+ A vibrant creating wonderful software and hope the future will be + brighter. +

+ + See some of our works + + +
+
+ galaxy +
+
+ + +
+ + diff --git a/src/pages/posts/[...slug].astro b/src/pages/en/posts/[...slug].astro similarity index 93% rename from src/pages/posts/[...slug].astro rename to src/pages/en/posts/[...slug].astro index cda8006..b1d9778 100644 --- a/src/pages/posts/[...slug].astro +++ b/src/pages/en/posts/[...slug].astro @@ -5,9 +5,9 @@ import sanitizeHtml from 'sanitize-html' import { Icon } from 'astro-icon/components' import { marked } from 'marked' -import Layout from '../../layouts/Layout.astro' -import AttachmentRenderer from '../../components/AttachmentRenderer.astro' -import { getAttachmentUrl, fetchAttachmentMeta } from '../../scripts/attachment' +import Layout from '@/layouts/Layout.astro' +import AttachmentRenderer from '@/components/AttachmentRenderer.astro' +import { getAttachmentUrl, fetchAttachmentMeta } from '@/scripts/attachment' const { slug } = Astro.params diff --git a/src/pages/products/solar-network.astro b/src/pages/en/products/solar-network.astro similarity index 99% rename from src/pages/products/solar-network.astro rename to src/pages/en/products/solar-network.astro index 9bab648..a2fe814 100644 --- a/src/pages/products/solar-network.astro +++ b/src/pages/en/products/solar-network.astro @@ -2,7 +2,7 @@ import { Image } from 'astro:assets' import { Icon } from 'astro-icon/components' -import Layout from '../../layouts/Layout.astro' +import Layout from '@/layouts/Layout.astro' import ProductSnPreviewImage from '../../assets/images/products/solar-network-alpha.webp' --- diff --git a/src/pages/terms/index.astro b/src/pages/en/terms/index.astro similarity index 93% rename from src/pages/terms/index.astro rename to src/pages/en/terms/index.astro index 6a52fd2..77a68e6 100644 --- a/src/pages/terms/index.astro +++ b/src/pages/en/terms/index.astro @@ -1,5 +1,5 @@ --- -import Layout from '../../layouts/Layout.astro' +import Layout from '@/layouts/Layout.astro' --- @@ -15,8 +15,8 @@ import Layout from '../../layouts/Layout.astro'

We're trying to make it as simple as possible. And it's good for both of - us. You do not need care about this in normal. Just makes our laywers - happy. Do we really have a laywer? + us. You do not need care about this in normal. Just makes our lawyers + happy. Do we really have a lawyer?

diff --git a/src/pages/terms/privacy-policy.astro b/src/pages/en/terms/privacy-policy.astro similarity index 97% rename from src/pages/terms/privacy-policy.astro rename to src/pages/en/terms/privacy-policy.astro index 8b5f352..6e4eb91 100644 --- a/src/pages/terms/privacy-policy.astro +++ b/src/pages/en/terms/privacy-policy.astro @@ -1,5 +1,5 @@ --- -import Layout from '../../layouts/Layout.astro' +import Layout from '@/layouts/Layout.astro' --- diff --git a/src/pages/terms/user-agreements.astro b/src/pages/en/terms/user-agreements.astro similarity index 99% rename from src/pages/terms/user-agreements.astro rename to src/pages/en/terms/user-agreements.astro index 1fc5a2c..6b71f0d 100644 --- a/src/pages/terms/user-agreements.astro +++ b/src/pages/en/terms/user-agreements.astro @@ -1,5 +1,5 @@ --- -import Layout from '../../layouts/Layout.astro' +import Layout from '@/layouts/Layout.astro' --- diff --git a/src/pages/index.astro b/src/pages/index.astro index 6fd09a1..0bed359 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,107 +1,12 @@ --- -import { Image } from 'astro:assets' -import { Icon } from 'astro-icon/components' - -import Layout from '../layouts/Layout.astro' - -import CompanyAsideImage from '../assets/images/company-aside.webp' -import AppStoreGetImage from '../assets/images/app-store/get-it-on-black.svg' -import ProductSnPreviewImage from '../assets/images/products/solar-network.webp' +import Layout from '@/layouts/Layout.astro' --- - -

-
-

Solsynth LLC

-

- A vibrant creating wonderful software and hope the future will be - brighter. -

- - See some of our works - - -
-
- galaxy -
-
- -