diff --git a/astro.config.mjs b/astro.config.mjs index 250c736..b58d321 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,11 +1,10 @@ import { defineConfig } from 'astro/config'; -import astroI18next from "astro-i18next"; import node from "@astrojs/node"; // https://astro.build/config export default defineConfig({ - integrations: [astroI18next()], + integrations: [], output: "hybrid", adapter: node({ mode: "middleware", diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 117c459..7763083 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -1,24 +1,32 @@ +--- + +import { getLangFromUrl, useTranslations } from "../i18n/utils" +const lang = getLangFromUrl(Astro.url); +const t = useTranslations(lang); + +--- + diff --git a/src/components/GameItem.astro b/src/components/GameItem.astro index 922bbfe..a8d5f8f 100644 --- a/src/components/GameItem.astro +++ b/src/components/GameItem.astro @@ -3,7 +3,7 @@ const { name, image, slugName } = Astro.props; ---
- +

{name}

diff --git a/src/i18n/en.json b/src/i18n/en.json new file mode 100644 index 0000000..247bea4 --- /dev/null +++ b/src/i18n/en.json @@ -0,0 +1,14 @@ +{ + "nav.brand": "Alu", + "nav.games": "Games", + "nav.settings": "Settings", + + "menu.welcome": "Welcome to Alu", + "menu.search": "Search...", + + "footer.brand": "Alu", + "footer.madeWithLove": "Made with ❤️ by wearr", + "footer.services": "Services", + "footer.socials": "Socials", + "footer.aluProject": "Alu Project" +} \ No newline at end of file diff --git a/src/i18n/jp.json b/src/i18n/jp.json new file mode 100644 index 0000000..e820145 --- /dev/null +++ b/src/i18n/jp.json @@ -0,0 +1,14 @@ +{ + "nav.brand": "アルー", + "nav.games": "ゲーム", + "nav.settings": "設定", + + "menu.welcome": "アルーにようこそ", + "menu.search": "検索...", + + "footer.brand": "アルー", + "footer.madeWithLove": "「wearr」による❤️で作られました", + "footer.services": "サービス", + "footer.socials": "ソーシャル", + "footer.aluProject": "アループロジェクト" +} \ No newline at end of file diff --git a/src/i18n/ui.ts b/src/i18n/ui.ts index 7e3dd14..e5679bd 100644 --- a/src/i18n/ui.ts +++ b/src/i18n/ui.ts @@ -1,19 +1,15 @@ +import en from './en.json'; +import jp from './jp.json'; + + export const languages = { en: 'English', jp: "日本語", }; - export const defaultLang = 'en'; +export const defaultLang = 'en'; - export const ui = { - en: { - 'nav.brand': 'Alu', - 'nav.games': "Games", - 'nav.settings': "Settings", - }, - jp: { - 'nav.brand': 'アルー', - 'nav.games': "ゲーム", - 'nav.settings': "設定", - }, - } as const; \ No newline at end of file +export const ui = { + en, + jp +}; \ No newline at end of file diff --git a/src/pages/en/404.astro b/src/pages/404.astro similarity index 83% rename from src/pages/en/404.astro rename to src/pages/404.astro index d1fb9da..8d3b0ea 100644 --- a/src/pages/en/404.astro +++ b/src/pages/404.astro @@ -1,5 +1,5 @@ --- -import Layout from "../../layouts/Layout.astro"; +import Layout from "../layouts/Layout.astro"; --- diff --git a/src/pages/jp/games.astro b/src/pages/[lang]/games.astro similarity index 98% rename from src/pages/jp/games.astro rename to src/pages/[lang]/games.astro index 8d05d79..c204c69 100644 --- a/src/pages/jp/games.astro +++ b/src/pages/[lang]/games.astro @@ -1,6 +1,13 @@ --- import Layout from "../../layouts/Layout.astro"; import GameItem from "../../components/GameItem.astro"; + +export function getStaticPaths () { + return [ + {params: {lang: 'en'}}, + {params: {lang: 'jp'}}, + ]; +} --- diff --git a/src/pages/jp/index.astro b/src/pages/[lang]/index.astro similarity index 74% rename from src/pages/jp/index.astro rename to src/pages/[lang]/index.astro index ee90b11..e657cd6 100644 --- a/src/pages/jp/index.astro +++ b/src/pages/[lang]/index.astro @@ -1,13 +1,24 @@ --- import Layout from "../../layouts/Layout.astro"; import UVRegistrar from "../../components/UVRegistrar.astro"; + +import { getLangFromUrl, useTranslations } from "../../i18n/utils" +const lang = getLangFromUrl(Astro.url); +const t = useTranslations(lang); + +export function getStaticPaths () { + return [ + {params: {lang: 'en'}}, + {params: {lang: 'jp'}}, + ]; +} ---
-

Welcome to Alu

+

{t("menu.welcome")}

- +
Loading...
diff --git a/src/pages/en/settings.astro b/src/pages/[lang]/settings.astro similarity index 72% rename from src/pages/en/settings.astro rename to src/pages/[lang]/settings.astro index c385721..813811b 100644 --- a/src/pages/en/settings.astro +++ b/src/pages/[lang]/settings.astro @@ -1,6 +1,13 @@ --- import SettingsTablist from "../../components/SettingsTablist.astro"; import Layout from "../../layouts/Layout.astro"; + +export function getStaticPaths () { + return [ + {params: {lang: 'en'}}, + {params: {lang: 'jp'}}, + ]; +} --- diff --git a/src/pages/en/games.astro b/src/pages/en/games.astro deleted file mode 100644 index 8d05d79..0000000 --- a/src/pages/en/games.astro +++ /dev/null @@ -1,92 +0,0 @@ ---- -import Layout from "../../layouts/Layout.astro"; -import GameItem from "../../components/GameItem.astro"; ---- - - -

Games

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - \ No newline at end of file diff --git a/src/pages/en/index.astro b/src/pages/en/index.astro deleted file mode 100644 index ee90b11..0000000 --- a/src/pages/en/index.astro +++ /dev/null @@ -1,64 +0,0 @@ ---- -import Layout from "../../layouts/Layout.astro"; -import UVRegistrar from "../../components/UVRegistrar.astro"; ---- - - -
-

Welcome to Alu

- - -
Loading...
-
- - -
- -
- - \ No newline at end of file diff --git a/src/pages/jp/404.astro b/src/pages/jp/404.astro deleted file mode 100644 index d1fb9da..0000000 --- a/src/pages/jp/404.astro +++ /dev/null @@ -1,16 +0,0 @@ ---- -import Layout from "../../layouts/Layout.astro"; ---- - - -
-

404!

-

The content you have requested could not be found!

-
-
- - \ No newline at end of file diff --git a/src/pages/jp/settings.astro b/src/pages/jp/settings.astro deleted file mode 100644 index 0f66abf..0000000 --- a/src/pages/jp/settings.astro +++ /dev/null @@ -1,20 +0,0 @@ ---- -import { changeLanguage } from "i18next"; -import Switch from "../../components/Switch.astro"; -import SettingsTablist from "../../components/SettingsTablist.astro"; -import Layout from "../../layouts/Layout.astro"; -import ThemeLoader from "../../components/ThemeLoader.astro"; - -changeLanguage("en"); ---- - - -

Settings

- -
- - \ No newline at end of file