feat: implement internationalization and routing for locale-based pages
- Added RootLayout component to handle locale and message loading. - Created Home page with header, about info, products, and story sections. - Developed ProductPage for displaying product categories and products. - Implemented ProductsPage to list product categories with banners. - Added Projects page with a grid layout for project display. - Configured server settings for port and host. - Established navigation and routing for internationalization. - Set up request handling for locale and message retrieval. - Defined routing structure for supported locales. - Created middleware for locale-based routing. - Defined layout parameters for locale handling.
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import Footer from '@/components/layout/footer/Footer';
|
||||
import '@/app/globals.css';
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
import { notFound } from 'next/navigation';
|
||||
import { NextIntlClientProvider } from 'next-intl';
|
||||
import type { ILayoutLocaleParams } from '@/models/layout.d';
|
||||
|
||||
// export const metadata: Metadata = {
|
||||
// title: 'Create Next App',
|
||||
// description: 'Generated by create next app',
|
||||
// };
|
||||
|
||||
export default async function RootLayout({
|
||||
children,
|
||||
params,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
params: ILayoutLocaleParams;
|
||||
}>) {
|
||||
const locale = params.locale;
|
||||
console.log(locale);
|
||||
|
||||
let messages;
|
||||
try {
|
||||
console.log(await import(`../../../messages/en.json`));
|
||||
messages = (await import(`../../../messages/en.json`)).default;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<html lang={locale} dir={locale === 'fa' ? 'rtl' : 'ltr'}>
|
||||
<body className="min-h-svh w-full overflow-x-hidden">
|
||||
<NextIntlClientProvider locale={locale} messages={messages}>
|
||||
{children}
|
||||
<Footer />
|
||||
</NextIntlClientProvider>
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user