Skip to content

feat: Setup i18n migration #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import createNextIntlPlugin from "next-intl/plugin";
/** @type {import('next').NextConfig} */
const nextConfig = {};

export default nextConfig;
const withNextIntl = createNextIntlPlugin();
export default withNextIntl(nextConfig);
122 changes: 122 additions & 0 deletions package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
"lint": "next lint"
},
"dependencies": {
"next": "15.2.2",
"next-intl": "^3.26.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"next": "15.2.2"
"react-dom": "^19.0.0"
},
"devDependencies": {
"@tailwindcss/postcss": "^4",
Expand Down
22 changes: 14 additions & 8 deletions src/app/layout.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { NextIntlClientProvider } from "next-intl";
import { getMessages } from "next-intl/server";
import { Geist, Geist_Mono } from "next/font/google";
import "./globals.css";

Expand All @@ -16,14 +18,18 @@ export const metadata = {
description: "Generated by create next app",
};

export default function RootLayout({ children }) {
export default async function RootLayout({ children }) {
const messages = await getMessages();

return (
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
{children}
</body>
</html>
<NextIntlClientProvider messages={messages}>
<html lang="en">
<body
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
>
{children}
</body>
</html>
</NextIntlClientProvider>
);
}
12 changes: 12 additions & 0 deletions src/i18n/request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { getRequestConfig } from "next-intl/server";

export default getRequestConfig(async () => {
// Provide a static locale, fetch a user setting,
// read from `cookies()`, `headers()`, etc.
const locale = "en";

return {
locale,
messages: (await import(`../messages/${locale}.json`)).default,
};
});