0.0.7 • Published 2 years ago

next-i18n-middleware v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

next-i18n-middleware

This is a package created to handle i18n in Next.js projects.

Install

# NPM
npm install --save next-i18n-middleware

Example

// middleware.ts at the root of the project

import { createMiddleware } from "next-i18n-middleware";

export default createMiddleware({
  // A list of all locales that are supported
  locales: ["en", "de"],

  defaultLocale: "en",
});

export const config = {
  // Skip all paths that should not be internationalized
  matcher: ["/((?!api|_next|.*\\..*).*)"],
};
// app/[locale]/layout.tsx

export default function RootLayout({ children, params: { locale } }) {
// pass locale to your i18n lib
  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  );
}

File Structure

├── middleware.ts 
└── app
    └── [locale]
        ├── layout.tsx 
        └── page.tsx 
0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago