From 3b60461f4d3359cd0ef957c36727c9a3fa6bc0ac Mon Sep 17 00:00:00 2001 From: So Asano Date: Sat, 13 Apr 2024 05:08:14 +0900 Subject: [PATCH] =?UTF-8?q?i18n=20=E5=AF=BE=E5=BF=9C=E3=81=AE=E5=AE=9F?= =?UTF-8?q?=E9=A8=93=20(#91)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astro/.eslintrc.cjs | 1 + astro/.gitignore | 3 + astro/astro.config.mjs | 58 +++++++---- astro/package-lock.json | 196 +++++++++++++++++++++++++++++++++++- astro/package.json | 1 + astro/src/pages/index.astro | 9 +- 6 files changed, 245 insertions(+), 23 deletions(-) diff --git a/astro/.eslintrc.cjs b/astro/.eslintrc.cjs index bd4d9f2..abad064 100644 --- a/astro/.eslintrc.cjs +++ b/astro/.eslintrc.cjs @@ -52,6 +52,7 @@ module.exports = { "tailwind.config.mjs", "jest.config.cjs", "astro.config.mjs", + "astro-i18next.config.ts", ], overrides: [ { diff --git a/astro/.gitignore b/astro/.gitignore index ad5086e..a796a40 100644 --- a/astro/.gitignore +++ b/astro/.gitignore @@ -21,3 +21,6 @@ pnpm-debug.log* # macOS-specific files .DS_Store + +# i18n +astro_tmp_pages_* diff --git a/astro/astro.config.mjs b/astro/astro.config.mjs index 61362f9..6a66cf4 100644 --- a/astro/astro.config.mjs +++ b/astro/astro.config.mjs @@ -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(), -}); \ No newline at end of file + 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" diff --git a/astro/package-lock.json b/astro/package-lock.json index 997b292..c940c85 100644 --- a/astro/package-lock.json +++ b/astro/package-lock.json @@ -1,12 +1,12 @@ { "name": "skyshare", - "version": "1.4.7", + "version": "1.4.11", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "skyshare", - "version": "1.4.7", + "version": "1.4.11", "dependencies": { "@astrojs/check": "^0.4.1", "@astrojs/cloudflare": "^8.1.0", @@ -19,6 +19,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", @@ -2697,6 +2698,90 @@ "url": "https://opencollective.com/unts" } }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.13.0.tgz", + "integrity": "sha512-5ZYPOuaAqEH/W3gYsRkxQATBW3Ii1MfaT4EQstTnLKViLi2gLSQmlmtTpGucNP3sXEpOiI5tdGhjdE111ekyEg==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.13.0.tgz", + "integrity": "sha512-BSbaCmn8ZadK3UAQdlauSvtaJjhlDEjS5hEVVIN3A4bbl3X+otyf/kOJV08bYiRxfejP3DXFzO2jz3G20107+Q==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.13.0.tgz", + "integrity": "sha512-U+Jcxm89UTK592vZ2J9st9ajRv/hrwHdnvyuJpa5A2ngGSVHypigidkQJP+YiGL6JODiUeMzkqQzbCG3At81Gg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.13.0.tgz", + "integrity": "sha512-8wZidaUJUTIR5T4vRS22VkSMOVooG0F4N+JSwQXWSRiC6yfEsFMLTYRFHvby5mFFuExHa/yAp9juSphQQJAijQ==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.13.0.tgz", + "integrity": "sha512-Iu0Kno1vrD7zHQDxOmvweqLkAzjxEVqNhUIXBsZ8hu8Oak7/5VTPrxOEZXYC1nmrBVJp0ZcL2E7lSuuOVaE3+w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.13.0.tgz", + "integrity": "sha512-C31QrW47llgVyrRjIwiOwsHFcaIwmkKi3PCroQY5aVq4H0A5v/vVVAtFsI1nfBngtoRpeREvZOkIhmRwUKkAdw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.13.0.tgz", + "integrity": "sha512-Oq90dtMHvthFOPMl7pt7KmxzX7E71AfyIhh+cPhLY9oko97Zf2C9tt/XJD4RgxhaGeAraAXDtqxvKE1y/j35lA==", + "cpu": [ + "riscv64" + ], + "optional": true, + "os": [ + "linux" + ] + }, "node_modules/@rollup/rollup-linux-x64-gnu": { "version": "4.13.0", "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.13.0.tgz", @@ -2721,6 +2806,42 @@ "linux" ] }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.13.0.tgz", + "integrity": "sha512-46ue8ymtm/5PUU6pCvjlic0z82qWkxv54GTJZgHrQUuZnVH+tvvSP0LsozIDsCBFO4VjJ13N68wqrKSeScUKdA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.13.0.tgz", + "integrity": "sha512-P5/MqLdLSlqxbeuJ3YDeX37srC8mCflSyTrUsgbU1c/U9j6l2g2GiIdYaGD9QjdMQPMSgYm7hgg0551wHyIluw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.13.0.tgz", + "integrity": "sha512-UKXUQNbO3DOhzLRwHSpa0HnhhCgNODvfoPWv2FCXme8N/ANFfhIPMGuOT+QuKd16+B5yxZ0HdpNlqPvTMS1qfw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@shikijs/core": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/@shikijs/core/-/core-1.1.7.tgz", @@ -3884,6 +4005,64 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/astro-i18n-aut": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/astro-i18n-aut/-/astro-i18n-aut-0.7.0.tgz", + "integrity": "sha512-IPcjs5NkaNJIrTYDbLx+ay6J6LbAG0QMGE8LwjGmS6JuJHmFRbkmVnqW/OYYZhrHOxOhruhCwfY0bWo5K0TGrA==", + "dependencies": { + "dedent": "^1.5.1", + "fast-glob": "^3.3.1", + "fs-extra": "^11.1.1", + "slash": "^5.1.0" + }, + "peerDependencies": { + "astro": "^4.0.3", + "kleur": "^4.1.4" + } + }, + "node_modules/astro-i18n-aut/node_modules/fs-extra": { + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz", + "integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==", + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, + "node_modules/astro-i18n-aut/node_modules/jsonfile": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "dependencies": { + "universalify": "^2.0.0" + }, + "optionalDependencies": { + "graceful-fs": "^4.1.6" + } + }, + "node_modules/astro-i18n-aut/node_modules/slash": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-5.1.0.tgz", + "integrity": "sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==", + "engines": { + "node": ">=14.16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/astro-i18n-aut/node_modules/universalify": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", + "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==", + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/astro/node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", @@ -5335,7 +5514,6 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/dedent/-/dedent-1.5.1.tgz", "integrity": "sha512-+LxW+KLWxu3HW3M2w2ympwtqPrqYRzU8fqi6Fhd18fBALe15blJPI/I4+UHveMVG6lJqB4JNd4UG0S5cnVHwIg==", - "dev": true, "peerDependencies": { "babel-plugin-macros": "^3.1.0" }, @@ -14075,6 +14253,18 @@ "fsevents": "~2.3.2" } }, + "node_modules/rollup/node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.13.0.tgz", + "integrity": "sha512-Ovf2evVaP6sW5Ut0GHyUSOqA6tVKfrTHddtmxGQc1CTQa1Cw3/KMCDEEICZBbyppcwnhMwcDce9ZRxdWRpVd6g==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ] + }, "node_modules/rtl-css-js": { "version": "1.16.1", "resolved": "https://registry.npmjs.org/rtl-css-js/-/rtl-css-js-1.16.1.tgz", diff --git a/astro/package.json b/astro/package.json index fa0dafa..430b5dc 100755 --- a/astro/package.json +++ b/astro/package.json @@ -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", diff --git a/astro/src/pages/index.astro b/astro/src/pages/index.astro index 650e21e..ba1d4e2 100644 --- a/astro/src/pages/index.astro +++ b/astro/src/pages/index.astro @@ -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) + --- Blueskyへログイン + >Blueskyにサインイン + {locale === "ja" ? "(日本語やで)" : + locale === "en" ? "(英語やで)" : "(言語不明やで)"}