Skip to content

Commit

Permalink
i18n 対応の実験 (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
so-asano authored and nkte8 committed Apr 13, 2024
1 parent f42b9de commit 3b60461
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 23 deletions.
1 change: 1 addition & 0 deletions astro/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module.exports = {
"tailwind.config.mjs",
"jest.config.cjs",
"astro.config.mjs",
"astro-i18next.config.ts",
],
overrides: [
{
Expand Down
3 changes: 3 additions & 0 deletions astro/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ pnpm-debug.log*

# macOS-specific files
.DS_Store

# i18n
astro_tmp_pages_*
58 changes: 39 additions & 19 deletions astro/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
import { defineConfig } from 'astro/config';
import react from "@astrojs/react";
import tailwind from "@astrojs/tailwind";
import cloudflare from "@astrojs/cloudflare";
import partytown from '@astrojs/partytown';
import { defineConfig } from "astro/config"
import react from "@astrojs/react"
import tailwind from "@astrojs/tailwind"
import cloudflare from "@astrojs/cloudflare"
import partytown from "@astrojs/partytown"
import { i18n } from "astro-i18n-aut/integration"

const defaultLocale = "ja"
const locales = {
ja: "ja", // the `defaultLocale` value must present in `locales` keys
en: "en",
}

// https://astro.build/config
/** @type {import('tailwindcss').Config} */
export default defineConfig({
base: "/",
site: "https://skyshare.uk/",
server: {
port: 4321,
host: true
},
integrations: [
react(),
tailwind(),
partytown()
],
output: "hybrid",
adapter: cloudflare(),
});
base: "/",
site: "https://skyshare.uk/",
server: {
port: 4321,
host: true,
},
integrations: [
react(),
tailwind(),
partytown(),
i18n({
locales,
defaultLocale,
}),
],
output: "hybrid",
adapter: cloudflare(),
trailingSlash: "always",
build: {
format: "directory",
},
routing: {
prefixDefaultLocale: true,
},
})

import { defineConfig } from "astro/config"
196 changes: 193 additions & 3 deletions astro/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@types/react": "^18.2.47",
"@types/react-dom": "^18.2.18",
"astro": "^4.1.2",
"astro-i18n-aut": "^0.7.0",
"browser-image-compression": "^2.0.2",
"cheerio": "^1.0.0-rc.12",
"js-base64": "^3.7.6",
Expand Down
9 changes: 8 additions & 1 deletion astro/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import Xicon from "@/components/Xicon.astro"
import Bskyicon from "@/components/Bskyicon.astro"
const robots = ["index", "follow", "noarchive", "noimageindex"]
import { getLocale } from "astro-i18n-aut"
const locale = getLocale(Astro.url)
---

<Pagelayout
Expand Down Expand Up @@ -46,7 +51,9 @@ const robots = ["index", "follow", "noarchive", "noimageindex"]
bg-opacity-80 border-0 py-4 px-10
focus:outline-none hover:bg-sky-200
inline-flex rounded-full transition-colors shadow-md"
>Blueskyへログイン
>Blueskyにサインイン
{locale === "ja" ? "(日本語やで)" :
locale === "en" ? "(英語やで)" : "(言語不明やで)"}
</a>
<div class="text-center mx-auto md:max-w-3xl my-5">
<div
Expand Down

0 comments on commit 3b60461

Please sign in to comment.