From 4522a590525d7e0ffc2aa624b4de1c20cc154e14 Mon Sep 17 00:00:00 2001 From: misogihagi <47350059+misogihagi@users.noreply.github.com> Date: Tue, 20 May 2025 00:06:37 +0900 Subject: [PATCH] add completed example --- app/[lng]/page.js | 5 +++-- app/i18n/index.js | 8 ++------ next.config.js | 4 +++- public/index.html | 19 +++++++++++++++++++ 4 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 public/index.html diff --git a/app/[lng]/page.js b/app/[lng]/page.js index d358163..9162562 100644 --- a/app/[lng]/page.js +++ b/app/[lng]/page.js @@ -4,8 +4,9 @@ import { Header } from './components/Header' import { Footer } from './components/Footer' import { Link } from './components/Link' -export default async function Page() { - const { t } = await getT() +export default async function Page({ params }) { + const { lng } = await params + const { t } = await getT(lng, 'second-page') return ( <> diff --git a/app/i18n/index.js b/app/i18n/index.js index f3605b1..a9b79ef 100644 --- a/app/i18n/index.js +++ b/app/i18n/index.js @@ -1,10 +1,6 @@ import i18next from './i18next' -import { headerName } from './settings' -import { headers } from 'next/headers' -export async function getT(ns, options) { - const headerList = await headers() - const lng = headerList.get(headerName) +export async function getT(lng, ns, options) { if (lng && i18next.resolvedLanguage !== lng) { await i18next.changeLanguage(lng) } @@ -15,4 +11,4 @@ export async function getT(ns, options) { t: i18next.getFixedT(lng ?? i18next.resolvedLanguage, Array.isArray(ns) ? ns[0] : ns, options?.keyPrefix), i18n: i18next } -} \ No newline at end of file +} diff --git a/next.config.js b/next.config.js index 622c242..13f5509 100644 --- a/next.config.js +++ b/next.config.js @@ -1,6 +1,8 @@ /** @type {import('next').NextConfig} */ const nextConfig = { - reactStrictMode: true // Recommended for the `pages` directory, default in `app`. + output: 'export', + trailingSlash: true, + reactStrictMode: true } module.exports = nextConfig diff --git a/public/index.html b/public/index.html new file mode 100644 index 0000000..e0087e3 --- /dev/null +++ b/public/index.html @@ -0,0 +1,19 @@ + + +
+ + +