diff --git a/declarations.d.ts b/declarations.d.ts new file mode 100644 index 0000000..bbab69d --- /dev/null +++ b/declarations.d.ts @@ -0,0 +1,4 @@ +declare module '*.json' { + const value: any; + export default value; +} diff --git a/global.ts b/global.ts new file mode 100644 index 0000000..acc506e --- /dev/null +++ b/global.ts @@ -0,0 +1,9 @@ +import { routing } from '@/i18n/routing'; +import messages from './messages/en.json'; + +declare module 'next-intl' { + interface AppConfig { + Locale: (typeof routing.locales)[number]; + Messages: typeof messages; + } +} diff --git a/messages/en.d.json.ts b/messages/en.d.json.ts new file mode 100644 index 0000000..26cb1c1 --- /dev/null +++ b/messages/en.d.json.ts @@ -0,0 +1,63 @@ +// This file is auto-generated by next-intl, do not edit directly. +// See: https://next-intl.dev/docs/workflows/typescript#messages-arguments + +declare const messages: { + "pages_home_title": "Home", + "pages_home_description": "Welcome to the home page", + "pages_about_title": "About Us", + "pages_about_description": "Learn more about us on this page", + "pages_contact_title": "Contact Us", + "pages_product_categories_title": "Products", + "pages_products_title": "Products", + "pages_blog_title": "Blog", + "pages_projects_title": "Projects", + "pages_contact_description": "Get in touch with us through this page", + "com_home_banner_title": "Excellence innovating", + "com_home_banner_title_bold": "industry for today", + "com_home_banner_description": "At the heart of our operations is a commitment to delivering superior products through cutting-
edge technology and innovative processes.", + "com_home_banner_button": " Explore More", + "com_home_Banner_link1": " Advanced Manufacturing Solutions", + "com_home_Banner_link2": "Quality Assurance Systems", + "com_home_Banner_link3": "State-of-the-Art Technology", + + "com_about_info_title": "Building quality through", + "com_about_info_title_bold": "industrial innovation", + "com_about_info_description": "At the heart of our operations is a commitment to delivering superior products through cutting-edge technology and innovative processes.", + "com_about_info_years_experience": "years of experience", + "com_about_info_achievements_1": "Sustainable Manufacturing", + "com_about_info_achievements_2": "Advanced Automation", + "com_about_info_achievements_3": "Efficient Production Processes", + "com_about_info_achievements_4": "Reliable Delivery Services", + + "com_home_products_title": "The Qualified bricks for Your Projects", + "com_home_products_description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", + + "footer_title": "Industrial Solutions for a Modern World", + "footer_description": "We are committed to providing personalized industrial solutions that meet the unique needs of our clients. Our team of experts is dedicated to delivering high-quality products and services that drive success in today’s competitive market.", + "footer_slogan": "We are committed to providing personalized industrial solutions.", + "footer_links_quick_links": "Quick Links", + "footer_links_who_we_are": "Who We Are", + "footer_links_contact": "Contact", + "footer_copyright": "Copyright © 2025 All Rights Reserved.", + "footer_links_address": "123 Industrial Ave, Suite 456, City, Country", + + "com_home_story_title": "Our Story", + "com_home_story_slogan": "Building quality through", + "com_home_story_slogan_bold": "industrial innovation", + "com_home_story_description": "We are a leading provider of industrial solutions, dedicated to delivering high-quality products and services that meet the unique needs of our clients. Our team of experts is committed to driving success in today’s competitive market through innovation and excellence.", + "com_home_story_projects_count": "Completed Projects", + "com_home_story_customer_count": "Happy Customers", + "com_home_story_experience": "Years of Experience", + + "com_products_category_Ghazaghi_title": "Ghazaghi", + "com_products_category_Ghermez_title": "Ghermez", + "com_products_category_Semirom_title": "Semirom", + "com_products_category_Zard_title": "Zard", + "com_products_category_types_count": "count Types", + "com_products_category_show_all_CTA": "Show Products", + "pages_products_content_title": "Brick Classification: Understanding the Variety and Applications", + "pages_products_content_description": "Bricks, as one of humanity's oldest and most widely used building materials, have evolved significantly throughout history. Today, they are produced and supplied in an incredibly diverse range, allowing engineers and architects to choose the most suitable brick for any project and need, from traditional and historic structures to modern and advanced buildings. To better understand this diversity, we can classify bricks based on several key criteria, each with its own specific characteristics and applications. \n 1. Classification by Manufacturing Method: From Tradition to Advanced IndustryThe method by which bricks are produced directly impacts their appearance, texture, and properties. Hand-moulded/Stock Bricks: These bricks are produced by manually pressing clay into molds. The result is a brick with a relatively rough texture, uneven edges, and a more traditional appearance, where each piece feels unique. This type of brick is often used for restoration projects or for constructing buildings with a rustic or antique style. Machine-made Bricks: These bricks are produced using industrial machinery, resulting in much higher precision in dimensions and uniformity in appearance. Machine-made bricks themselves are divided into two main categories: Perforated/Hollow Bricks: These bricks have holes, offering several advantages: they reduce building weight, improve thermal and acoustic insulation, and enhance mortar adhesion. Solid Bricks: These bricks are without holes and possess very high compressive strength. They are ideal for load-bearing structures and walls requiring maximum strength. 2. Classification by Raw Material Type and Composition: From Clay to Concrete The material from which a brick is made determines its physical and chemical properties.", + + "com_products_products_category_title": "Products of {title} Category" +}; +export default messages; \ No newline at end of file diff --git a/messages/en.json b/messages/en.json new file mode 100644 index 0000000..2d04522 --- /dev/null +++ b/messages/en.json @@ -0,0 +1,59 @@ +{ + "pages_home_title": "Home", + "pages_home_description": "Welcome to the home page", + "pages_about_title": "About Us", + "pages_about_description": "Learn more about us on this page", + "pages_contact_title": "Contact Us", + "pages_product_categories_title": "Products", + "pages_products_title": "Products", + "pages_blog_title": "Blog", + "pages_projects_title": "Projects", + "pages_contact_description": "Get in touch with us through this page", + "com_home_banner_title": "Excellence innovating", + "com_home_banner_title_bold": "industry for today", + "com_home_banner_description": "At the heart of our operations is a commitment to delivering superior products through cutting-
edge technology and innovative processes.", + "com_home_banner_button": " Explore More", + "com_home_Banner_link1": " Advanced Manufacturing Solutions", + "com_home_Banner_link2": "Quality Assurance Systems", + "com_home_Banner_link3": "State-of-the-Art Technology", + + "com_about_info_title": "Building quality through", + "com_about_info_title_bold": "industrial innovation", + "com_about_info_description": "At the heart of our operations is a commitment to delivering superior products through cutting-edge technology and innovative processes.", + "com_about_info_years_experience": "years of experience", + "com_about_info_achievements_1": "Sustainable Manufacturing", + "com_about_info_achievements_2": "Advanced Automation", + "com_about_info_achievements_3": "Efficient Production Processes", + "com_about_info_achievements_4": "Reliable Delivery Services", + + "com_home_products_title": "The Qualified bricks for Your Projects", + "com_home_products_description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", + + "footer_title": "Industrial Solutions for a Modern World", + "footer_description": "We are committed to providing personalized industrial solutions that meet the unique needs of our clients. Our team of experts is dedicated to delivering high-quality products and services that drive success in today’s competitive market.", + "footer_slogan": "We are committed to providing personalized industrial solutions.", + "footer_links_quick_links": "Quick Links", + "footer_links_who_we_are": "Who We Are", + "footer_links_contact": "Contact", + "footer_copyright": "Copyright © 2025 All Rights Reserved.", + "footer_links_address": "123 Industrial Ave, Suite 456, City, Country", + + "com_home_story_title": "Our Story", + "com_home_story_slogan": "Building quality through", + "com_home_story_slogan_bold": "industrial innovation", + "com_home_story_description": "We are a leading provider of industrial solutions, dedicated to delivering high-quality products and services that meet the unique needs of our clients. Our team of experts is committed to driving success in today’s competitive market through innovation and excellence.", + "com_home_story_projects_count": "Completed Projects", + "com_home_story_customer_count": "Happy Customers", + "com_home_story_experience": "Years of Experience", + + "com_products_category_Ghazaghi_title": "Ghazaghi", + "com_products_category_Ghermez_title": "Ghermez", + "com_products_category_Semirom_title": "Semirom", + "com_products_category_Zard_title": "Zard", + "com_products_category_types_count": "count Types", + "com_products_category_show_all_CTA": "Show Products", + "pages_products_content_title": "Brick Classification: Understanding the Variety and Applications", + "pages_products_content_description": "Bricks, as one of humanity's oldest and most widely used building materials, have evolved significantly throughout history. Today, they are produced and supplied in an incredibly diverse range, allowing engineers and architects to choose the most suitable brick for any project and need, from traditional and historic structures to modern and advanced buildings. To better understand this diversity, we can classify bricks based on several key criteria, each with its own specific characteristics and applications. \n 1. Classification by Manufacturing Method: From Tradition to Advanced IndustryThe method by which bricks are produced directly impacts their appearance, texture, and properties. Hand-moulded/Stock Bricks: These bricks are produced by manually pressing clay into molds. The result is a brick with a relatively rough texture, uneven edges, and a more traditional appearance, where each piece feels unique. This type of brick is often used for restoration projects or for constructing buildings with a rustic or antique style. Machine-made Bricks: These bricks are produced using industrial machinery, resulting in much higher precision in dimensions and uniformity in appearance. Machine-made bricks themselves are divided into two main categories: Perforated/Hollow Bricks: These bricks have holes, offering several advantages: they reduce building weight, improve thermal and acoustic insulation, and enhance mortar adhesion. Solid Bricks: These bricks are without holes and possess very high compressive strength. They are ideal for load-bearing structures and walls requiring maximum strength. 2. Classification by Raw Material Type and Composition: From Clay to Concrete The material from which a brick is made determines its physical and chemical properties.", + + "com_products_products_category_title": "Products of {title} Category" +} diff --git a/messages/fa.json b/messages/fa.json new file mode 100644 index 0000000..2d04522 --- /dev/null +++ b/messages/fa.json @@ -0,0 +1,59 @@ +{ + "pages_home_title": "Home", + "pages_home_description": "Welcome to the home page", + "pages_about_title": "About Us", + "pages_about_description": "Learn more about us on this page", + "pages_contact_title": "Contact Us", + "pages_product_categories_title": "Products", + "pages_products_title": "Products", + "pages_blog_title": "Blog", + "pages_projects_title": "Projects", + "pages_contact_description": "Get in touch with us through this page", + "com_home_banner_title": "Excellence innovating", + "com_home_banner_title_bold": "industry for today", + "com_home_banner_description": "At the heart of our operations is a commitment to delivering superior products through cutting-
edge technology and innovative processes.", + "com_home_banner_button": " Explore More", + "com_home_Banner_link1": " Advanced Manufacturing Solutions", + "com_home_Banner_link2": "Quality Assurance Systems", + "com_home_Banner_link3": "State-of-the-Art Technology", + + "com_about_info_title": "Building quality through", + "com_about_info_title_bold": "industrial innovation", + "com_about_info_description": "At the heart of our operations is a commitment to delivering superior products through cutting-edge technology and innovative processes.", + "com_about_info_years_experience": "years of experience", + "com_about_info_achievements_1": "Sustainable Manufacturing", + "com_about_info_achievements_2": "Advanced Automation", + "com_about_info_achievements_3": "Efficient Production Processes", + "com_about_info_achievements_4": "Reliable Delivery Services", + + "com_home_products_title": "The Qualified bricks for Your Projects", + "com_home_products_description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", + + "footer_title": "Industrial Solutions for a Modern World", + "footer_description": "We are committed to providing personalized industrial solutions that meet the unique needs of our clients. Our team of experts is dedicated to delivering high-quality products and services that drive success in today’s competitive market.", + "footer_slogan": "We are committed to providing personalized industrial solutions.", + "footer_links_quick_links": "Quick Links", + "footer_links_who_we_are": "Who We Are", + "footer_links_contact": "Contact", + "footer_copyright": "Copyright © 2025 All Rights Reserved.", + "footer_links_address": "123 Industrial Ave, Suite 456, City, Country", + + "com_home_story_title": "Our Story", + "com_home_story_slogan": "Building quality through", + "com_home_story_slogan_bold": "industrial innovation", + "com_home_story_description": "We are a leading provider of industrial solutions, dedicated to delivering high-quality products and services that meet the unique needs of our clients. Our team of experts is committed to driving success in today’s competitive market through innovation and excellence.", + "com_home_story_projects_count": "Completed Projects", + "com_home_story_customer_count": "Happy Customers", + "com_home_story_experience": "Years of Experience", + + "com_products_category_Ghazaghi_title": "Ghazaghi", + "com_products_category_Ghermez_title": "Ghermez", + "com_products_category_Semirom_title": "Semirom", + "com_products_category_Zard_title": "Zard", + "com_products_category_types_count": "count Types", + "com_products_category_show_all_CTA": "Show Products", + "pages_products_content_title": "Brick Classification: Understanding the Variety and Applications", + "pages_products_content_description": "Bricks, as one of humanity's oldest and most widely used building materials, have evolved significantly throughout history. Today, they are produced and supplied in an incredibly diverse range, allowing engineers and architects to choose the most suitable brick for any project and need, from traditional and historic structures to modern and advanced buildings. To better understand this diversity, we can classify bricks based on several key criteria, each with its own specific characteristics and applications. \n 1. Classification by Manufacturing Method: From Tradition to Advanced IndustryThe method by which bricks are produced directly impacts their appearance, texture, and properties. Hand-moulded/Stock Bricks: These bricks are produced by manually pressing clay into molds. The result is a brick with a relatively rough texture, uneven edges, and a more traditional appearance, where each piece feels unique. This type of brick is often used for restoration projects or for constructing buildings with a rustic or antique style. Machine-made Bricks: These bricks are produced using industrial machinery, resulting in much higher precision in dimensions and uniformity in appearance. Machine-made bricks themselves are divided into two main categories: Perforated/Hollow Bricks: These bricks have holes, offering several advantages: they reduce building weight, improve thermal and acoustic insulation, and enhance mortar adhesion. Solid Bricks: These bricks are without holes and possess very high compressive strength. They are ideal for load-bearing structures and walls requiring maximum strength. 2. Classification by Raw Material Type and Composition: From Clay to Concrete The material from which a brick is made determines its physical and chemical properties.", + + "com_products_products_category_title": "Products of {title} Category" +} diff --git a/middleware.ts b/middleware.ts new file mode 100644 index 0000000..63fa951 --- /dev/null +++ b/middleware.ts @@ -0,0 +1,43 @@ +import { NextResponse } from 'next/server'; +import type { NextRequest } from 'next/server'; + +const PUBLIC_FILE = /\.(.*)$/; +const locales = ['en', 'fa']; +const defaultLocale = 'en'; + +export function middleware(request: NextRequest) { + const { pathname } = request.nextUrl; + + // Ignore public files and API routes + if ( + pathname.startsWith('/api') || + PUBLIC_FILE.test(pathname) + ) { + return NextResponse.next(); + } + + // Check if the pathname already includes a locale + const pathnameIsMissingLocale = locales.every( + (locale) => !pathname.startsWith(`/${locale}/`) && pathname !== `/${locale}` + ); + + if (pathnameIsMissingLocale) { + // Redirect to default locale + return NextResponse.redirect( + new URL(`/${defaultLocale}${pathname}`, request.url) + ); + } + + return NextResponse.next(); +} + +export const config = { + matcher: [ + /* + Match all request paths except for: + - static files (/_next/static/) + - API routes (/api/) + */ + '/((?!_next/static|_next/image|favicon.ico|api).*)', + ], +}; \ No newline at end of file diff --git a/next-intl.ts b/next-intl.ts new file mode 100644 index 0000000..1ebee31 --- /dev/null +++ b/next-intl.ts @@ -0,0 +1,4 @@ +export default { + locales: ['en', 'fa'], + defaultLocale: 'en', +}; diff --git a/next.config.ts b/next.config.ts index b22af96..c049cbc 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,5 +1,12 @@ -import type { NextConfig } from 'next'; +import { NextConfig } from 'next'; +import createNextIntlPlugin from 'next-intl/plugin'; -const nextConfig: NextConfig = {}; +const withNextIntl = createNextIntlPlugin({ + experimental: { + createMessagesDeclaration: './messages/en.json', + }, +}); -export default nextConfig; +const config: NextConfig = {}; + +export default withNextIntl(config); diff --git a/package-lock.json b/package-lock.json index 3b96c41..c75439e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "axios": "^1.9.0", "leaflet": "^1.9.4", "next": "15.3.3", + "next-intl": "^4.1.0", "react": "^19.0.0", "react-dom": "^19.0.0", "react-leaflet": "^5.0.0" @@ -218,6 +219,60 @@ "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@formatjs/ecma402-abstract": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/@formatjs/ecma402-abstract/-/ecma402-abstract-2.3.4.tgz", + "integrity": "sha512-qrycXDeaORzIqNhBOx0btnhpD1c+/qFIHAN9znofuMJX6QBwtbrmlpWfD4oiUUD2vJUOIYFA/gYtg2KAMGG7sA==", + "dependencies": { + "@formatjs/fast-memoize": "2.2.7", + "@formatjs/intl-localematcher": "0.6.1", + "decimal.js": "^10.4.3", + "tslib": "^2.8.0" + } + }, + "node_modules/@formatjs/ecma402-abstract/node_modules/@formatjs/intl-localematcher": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.6.1.tgz", + "integrity": "sha512-ePEgLgVCqi2BBFnTMWPfIghu6FkbZnnBVhO2sSxvLfrdFw7wCHAHiDoM2h4NRgjbaY7+B7HgOLZGkK187pZTZg==", + "dependencies": { + "tslib": "^2.8.0" + } + }, + "node_modules/@formatjs/fast-memoize": { + "version": "2.2.7", + "resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-2.2.7.tgz", + "integrity": "sha512-Yabmi9nSvyOMrlSeGGWDiH7rf3a7sIwplbvo/dlz9WCIjzIQAfy1RMf4S0X3yG724n5Ghu2GmEl5NJIV6O9sZQ==", + "dependencies": { + "tslib": "^2.8.0" + } + }, + "node_modules/@formatjs/icu-messageformat-parser": { + "version": "2.11.2", + "resolved": "https://registry.npmjs.org/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-2.11.2.tgz", + "integrity": "sha512-AfiMi5NOSo2TQImsYAg8UYddsNJ/vUEv/HaNqiFjnI3ZFfWihUtD5QtuX6kHl8+H+d3qvnE/3HZrfzgdWpsLNA==", + "dependencies": { + "@formatjs/ecma402-abstract": "2.3.4", + "@formatjs/icu-skeleton-parser": "1.8.14", + "tslib": "^2.8.0" + } + }, + "node_modules/@formatjs/icu-skeleton-parser": { + "version": "1.8.14", + "resolved": "https://registry.npmjs.org/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-1.8.14.tgz", + "integrity": "sha512-i4q4V4qslThK4Ig8SxyD76cp3+QJ3sAqr7f6q9VVfeGtxG9OhiAk3y9XF6Q41OymsKzsGQ6OQQoJNY4/lI8TcQ==", + "dependencies": { + "@formatjs/ecma402-abstract": "2.3.4", + "tslib": "^2.8.0" + } + }, + "node_modules/@formatjs/intl-localematcher": { + "version": "0.5.10", + "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.5.10.tgz", + "integrity": "sha512-af3qATX+m4Rnd9+wHcjJ4w2ijq+rAVP3CCinJQvFv1kgSu1W6jypUmvleJxcewdxmutM8dmIRZFxO/IQBZmP2Q==", + "dependencies": { + "tslib": "2" + } + }, "node_modules/@humanfs/core": { "version": "0.19.1", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", @@ -939,6 +994,11 @@ "integrity": "sha512-zxnHvoMQVqewTJr/W4pKjF0bMGiKJv1WX7bSrkl46Hg0QjESbzBROWK0Wg4RphzSOS5Jiy7eFimmM3UgMrMZbQ==", "dev": true }, + "node_modules/@schummar/icu-type-parser": { + "version": "1.21.5", + "resolved": "https://registry.npmjs.org/@schummar/icu-type-parser/-/icu-type-parser-1.21.5.tgz", + "integrity": "sha512-bXHSaW5jRTmke9Vd0h5P7BtWZG9Znqb8gSDxZnxaGSJnGwPLDPfS+3g0BKzeWqzgZPsIVZkM7m2tbo18cm5HBw==" + }, "node_modules/@swc/counter": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", @@ -2336,6 +2396,11 @@ } } }, + "node_modules/decimal.js": { + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.5.0.tgz", + "integrity": "sha512-8vDa8Qxvr/+d94hSh5P3IJwI5t8/c0KsMp+g8bNw9cY2icONa5aPfvKeieW1WlG0WQYwwhJ7mjui2xtiePQSXw==" + }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -3527,6 +3592,17 @@ "node": ">= 0.4" } }, + "node_modules/intl-messageformat": { + "version": "10.7.16", + "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-10.7.16.tgz", + "integrity": "sha512-UmdmHUmp5CIKKjSoE10la5yfU+AYJAaiYLsodbjL4lji83JNvgOQUjGaGhGrpFCb0Uh7sl7qfP1IyILa8Z40ug==", + "dependencies": { + "@formatjs/ecma402-abstract": "2.3.4", + "@formatjs/fast-memoize": "2.2.7", + "@formatjs/icu-messageformat-parser": "2.11.2", + "tslib": "^2.8.0" + } + }, "node_modules/is-array-buffer": { "version": "3.0.5", "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz", @@ -4475,6 +4551,14 @@ "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "dev": true }, + "node_modules/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/next": { "version": "15.3.3", "resolved": "https://registry.npmjs.org/next/-/next-15.3.3.tgz", @@ -4528,6 +4612,32 @@ } } }, + "node_modules/next-intl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/next-intl/-/next-intl-4.1.0.tgz", + "integrity": "sha512-JNJRjc7sdnfUxhZmGcvzDszZ60tQKrygV/VLsgzXhnJDxQPn1cN2rVpc53adA1SvBJwPK2O6Sc6b4gYSILjCzw==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/amannn" + } + ], + "dependencies": { + "@formatjs/intl-localematcher": "^0.5.4", + "negotiator": "^1.0.0", + "use-intl": "^4.1.0" + }, + "peerDependencies": { + "next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0", + "typescript": "^5.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, "node_modules/next/node_modules/postcss": { "version": "8.4.31", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", @@ -5822,7 +5932,7 @@ "version": "5.8.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", - "dev": true, + "devOptional": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -5896,6 +6006,19 @@ "punycode": "^2.1.0" } }, + "node_modules/use-intl": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/use-intl/-/use-intl-4.1.0.tgz", + "integrity": "sha512-mQvDYFvoGn+bm/PWvlQOtluKCknsQ5a9F1Cj0hMfBjMBVTwnOqLPd6srhjvVdEQEQFVyHM1PfyifKqKYb11M9Q==", + "dependencies": { + "@formatjs/fast-memoize": "^2.2.0", + "@schummar/icu-type-parser": "1.21.5", + "intl-messageformat": "^10.5.14" + }, + "peerDependencies": { + "react": "^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0" + } + }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index e9b6247..af4798b 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "axios": "^1.9.0", "leaflet": "^1.9.4", "next": "15.3.3", + "next-intl": "^4.1.0", "react": "^19.0.0", "react-dom": "^19.0.0", "react-leaflet": "^5.0.0" diff --git a/src/app/[locale]/about-us/page.tsx b/src/app/[locale]/about-us/page.tsx new file mode 100644 index 0000000..3a711c3 --- /dev/null +++ b/src/app/[locale]/about-us/page.tsx @@ -0,0 +1,30 @@ +import images from '@/assets/images/images'; +import InnerPageBanner from '@/components/layout/innerPages/banner'; +import AboutTopInfo from '@/components/pages/about/TopInfo'; +import { ILayoutLocaleParams } from '@/models/layout'; +import { useTranslations } from 'next-intl'; +import { setRequestLocale } from 'next-intl/server'; +import { getTranslations } from 'next-intl/server'; + +export default async function AboutUs({ + params, +}: Readonly<{ + params: ILayoutLocaleParams; +}>) { + const { locale } = await params; + + // Enable static rendering + setRequestLocale(locale); + + const t = await getTranslations({ locale }); + + return ( +
+ + +
+ ); +} diff --git a/src/app/blog/page.tsx b/src/app/[locale]/blog/page.tsx similarity index 53% rename from src/app/blog/page.tsx rename to src/app/[locale]/blog/page.tsx index 10cf9bc..aab6f67 100644 --- a/src/app/blog/page.tsx +++ b/src/app/[locale]/blog/page.tsx @@ -1,20 +1,20 @@ import images from '@/assets/images/images'; import InnerPageBanner from '@/components/layout/innerPages/banner'; import PostsGrid from '@/components/pages/blog/PostsGrid'; -import { t } from '@/locales/translates'; +import { ILayoutLocaleParams } from '@/models/layout'; +import { getTranslations } from 'next-intl/server'; -async function getData() { - await new Promise((resolve) => setTimeout(resolve, 1000)); - return { message: 'This data was fetched on the server!' }; -} - -export default async function Blog() { - const data = await getData(); +export default async function Blog({ + params, +}: { + params: ILayoutLocaleParams; +}) { + const t = await getTranslations({ locale: params.locale }); return (
diff --git a/src/app/contact-us/page.tsx b/src/app/[locale]/contact-us/page.tsx similarity index 78% rename from src/app/contact-us/page.tsx rename to src/app/[locale]/contact-us/page.tsx index 98ca9ba..70bbc9f 100644 --- a/src/app/contact-us/page.tsx +++ b/src/app/[locale]/contact-us/page.tsx @@ -3,21 +3,21 @@ import InnerPageBanner from '@/components/layout/innerPages/banner'; import ContactMap from '@/components/layout/map'; import ContactForm from '@/components/pages/contact/ContactMeForm'; import TouchUs from '@/components/pages/contact/TouchUs'; -import { t } from '@/locales/translates'; import Image from 'next/image'; +import { getTranslations } from 'next-intl/server'; +import { ILayoutLocaleParams } from '@/models/layout'; -async function getData() { - await new Promise((resolve) => setTimeout(resolve, 1000)); - return { message: 'This data was fetched on the server!' }; -} - -export default async function Contact() { - const data = await getData(); +export default async function Contact({ + params, +}: { + params: ILayoutLocaleParams; +}) { + const t = await getTranslations({ locale: params.locale }); return (
diff --git a/src/app/[locale]/favicon.ico b/src/app/[locale]/favicon.ico new file mode 100644 index 0000000..718d6fe Binary files /dev/null and b/src/app/[locale]/favicon.ico differ diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx new file mode 100644 index 0000000..4cfb0ff --- /dev/null +++ b/src/app/[locale]/layout.tsx @@ -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 ( + + + + {children} +