From 12775285ecf36d84690f287873ad7b3f4191b94d Mon Sep 17 00:00:00 2001 From: ahasani194 Date: Sun, 8 Jun 2025 09:25:38 +0330 Subject: [PATCH 1/4] feat: implement internationalization support by updating locale files and adding language switch component --- messages/en.d.json.ts | 63 ----------- messages/fa.json | 102 +++++++++--------- package-lock.json | 16 +++ package.json | 1 + src/app/[...not_found]/layout.tsx | 35 ++++++ src/app/[...not_found]/page.tsx | 2 +- src/app/[locale]/layout.tsx | 8 +- src/assets/constants/footerMenu/index.ts | 2 +- .../constants/footerMenu/quickLinks.const.ts | 3 +- .../constants/footerMenu/whoAreWe.const.ts | 2 +- src/components/layout/footer/Footer.tsx | 4 +- src/components/layout/footer/FooterInfo.tsx | 2 + .../layout/languageSwitch/index.tsx | 28 +++++ src/components/layout/map/index.tsx | 3 +- src/components/pages/home/Products.tsx | 2 +- src/locales/en.ts | 97 ----------------- src/locales/fa.ts | 40 ------- src/locales/translates.ts | 69 ------------ src/models/layout.d.ts | 2 + 19 files changed, 148 insertions(+), 333 deletions(-) delete mode 100644 messages/en.d.json.ts create mode 100644 src/app/[...not_found]/layout.tsx create mode 100644 src/components/layout/languageSwitch/index.tsx delete mode 100644 src/locales/en.ts delete mode 100644 src/locales/fa.ts delete mode 100644 src/locales/translates.ts diff --git a/messages/en.d.json.ts b/messages/en.d.json.ts deleted file mode 100644 index 26cb1c1..0000000 --- a/messages/en.d.json.ts +++ /dev/null @@ -1,63 +0,0 @@ -// 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/fa.json b/messages/fa.json index 2d04522..7493c64 100644 --- a/messages/fa.json +++ b/messages/fa.json @@ -1,59 +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", + "pages_home_title": "خانه", + "pages_home_description": "به صفحه اصلی خوش آمدید", + "pages_about_title": "درباره ما", + "pages_about_description": "در این صفحه بیشتر درباره ما بدانید", + "pages_contact_title": "تماس با ما", + "pages_product_categories_title": "محصولات", + "pages_products_title": "محصولات", + "pages_blog_title": "وبلاگ", + "pages_projects_title": "پروژه‌ها", + "pages_contact_description": "از طریق این صفحه با ما در تماس باشید", + "com_home_banner_title": "نوآوری در تعالی", + "com_home_banner_title_bold": "صنعت برای امروز", + "com_home_banner_description": "در قلب فعالیت‌های ما تعهد به ارائه محصولات برتر از طریق فناوری پیشرفته و فرآیندهای نوآورانه قرار دارد.", + "com_home_banner_button": "بیشتر بدانید", + "com_home_Banner_link1": "راهکارهای پیشرفته تولید", + "com_home_Banner_link2": "سیستم‌های تضمین کیفیت", + "com_home_Banner_link3": "فناوری روز دنیا", - "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_about_info_title": "ساخت کیفیت از طریق", + "com_about_info_title_bold": "نوآوری صنعتی", + "com_about_info_description": "در قلب فعالیت‌های ما تعهد به ارائه محصولات برتر از طریق فناوری پیشرفته و فرآیندهای نوآورانه قرار دارد.", + "com_about_info_years_experience": "سال تجربه", + "com_about_info_achievements_1": "تولید پایدار", + "com_about_info_achievements_2": "اتوماسیون پیشرفته", + "com_about_info_achievements_3": "فرآیندهای تولید کارآمد", + "com_about_info_achievements_4": "خدمات تحویل قابل اعتماد", - "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.", + "com_home_products_title": "آجرهای با کیفیت برای پروژه‌های شما", + "com_home_products_description": "لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است.", - "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", + "footer_title": "راهکارهای صنعتی برای دنیای مدرن", + "footer_description": "ما متعهد به ارائه راهکارهای صنعتی شخصی‌سازی شده هستیم که نیازهای منحصر به فرد مشتریانمان را برآورده می‌کند. تیم متخصص ما به ارائه محصولات و خدمات با کیفیت بالا که موفقیت را در بازار رقابتی امروز تضمین می‌کند، متعهد است.", + "footer_slogan": "ما متعهد به ارائه راهکارهای صنعتی شخصی‌سازی شده هستیم.", + "footer_links_quick_links": "لینک‌های سریع", + "footer_links_who_we_are": "ما که هستیم", + "footer_links_contact": "تماس", + "footer_copyright": "کلیه حقوق محفوظ است © ۲۰۲۵", + "footer_links_address": "خیابان صنعتی ۱۲۳، واحد ۴۵۶، شهر، کشور", - "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_home_story_title": "داستان ما", + "com_home_story_slogan": "ساخت کیفیت از طریق", + "com_home_story_slogan_bold": "نوآوری صنعتی", + "com_home_story_description": "ما ارائه‌دهنده پیشرو راهکارهای صنعتی هستیم که به ارائه محصولات و خدمات با کیفیت بالا متعهدیم تا نیازهای منحصر به فرد مشتریانمان را برآورده کنیم. تیم متخصص ما با نوآوری و تعالی، موفقیت را در بازار رقابتی امروز تضمین می‌کند.", + "com_home_story_projects_count": "پروژه‌های انجام شده", + "com_home_story_customer_count": "مشتریان راضی", + "com_home_story_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_category_Ghazaghi_title": "غذاقی", + "com_products_category_Ghermez_title": "قرمز", + "com_products_category_Semirom_title": "سمیرم", + "com_products_category_Zard_title": "زرد", + "com_products_category_types_count": "تعداد نوع", + "com_products_category_show_all_CTA": "نمایش محصولات", + "pages_products_content_title": "طبقه‌بندی آجر: درک تنوع و کاربردها", + "pages_products_content_description": "آجرها به عنوان یکی از قدیمی‌ترین و پرکاربردترین مصالح ساختمانی بشر، در طول تاریخ دچار تحول زیادی شده‌اند. امروزه این مصالح در طیف بسیار متنوعی تولید و عرضه می‌شوند و به مهندسان و معماران این امکان را می‌دهند تا مناسب‌ترین آجر را برای هر پروژه و نیازی، از سازه‌های سنتی و تاریخی تا ساختمان‌های مدرن و پیشرفته، انتخاب کنند. برای درک بهتر این تنوع، می‌توان آجرها را بر اساس چند معیار کلیدی طبقه‌بندی کرد که هر یک ویژگی‌ها و کاربردهای خاص خود را دارند.\n۱. طبقه‌بندی بر اساس روش تولید: از سنت تا صنعت پیشرفته\nروش تولید آجرها مستقیماً بر ظاهر، بافت و ویژگی‌های آن‌ها تأثیر می‌گذارد.\nآجرهای دستی/قالبی: این آجرها با فشار دادن دستی خاک رس در قالب تولید می‌شوند. نتیجه، آجری با بافت نسبتاً زبر، لبه‌های نامنظم و ظاهری سنتی‌تر است که هر قطعه حس منحصر به فردی دارد. این نوع آجر اغلب برای پروژه‌های مرمت یا ساخت ساختمان‌هایی با سبک روستایی یا قدیمی استفاده می‌شود.\nآجرهای ماشینی: این آجرها با استفاده از ماشین‌آلات صنعتی تولید می‌شوند که دقت ابعادی و یکنواختی ظاهری بسیار بالاتری دارند. آجرهای ماشینی خود به دو دسته اصلی تقسیم می‌شوند:\nآجرهای سوراخ‌دار/توخالی: این آجرها دارای سوراخ‌هایی هستند که چندین مزیت دارند: کاهش وزن ساختمان، بهبود عایق حرارتی و صوتی و افزایش چسبندگی ملات.\nآجرهای توپر: این آجرها بدون سوراخ بوده و مقاومت فشاری بسیار بالایی دارند. آن‌ها برای سازه‌های باربر و دیوارهایی که به حداکثر استحکام نیاز دارند، ایده‌آل هستند.\n۲. طبقه‌بندی بر اساس نوع و ترکیب مواد اولیه: از خاک رس تا بتن\nجنس آجر تعیین‌کننده ویژگی‌های فیزیکی و شیمیایی آن است.", - "com_products_products_category_title": "Products of {title} Category" + "com_products_products_category_title": "محصولات دسته {title}" } diff --git a/package-lock.json b/package-lock.json index c75439e..245ed7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,7 @@ "devDependencies": { "@eslint/eslintrc": "^3", "@tailwindcss/postcss": "^4", + "@types/leaflet": "^1.9.18", "@types/node": "^20", "@types/react": "^19", "@types/react-dom": "^19", @@ -1289,6 +1290,12 @@ "integrity": "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==", "dev": true }, + "node_modules/@types/geojson": { + "version": "7946.0.16", + "resolved": "https://registry.npmjs.org/@types/geojson/-/geojson-7946.0.16.tgz", + "integrity": "sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==", + "dev": true + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -1301,6 +1308,15 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, + "node_modules/@types/leaflet": { + "version": "1.9.18", + "resolved": "https://registry.npmjs.org/@types/leaflet/-/leaflet-1.9.18.tgz", + "integrity": "sha512-ht2vsoPjezor5Pmzi5hdsA7F++v5UGq9OlUduWHmMZiuQGIpJ2WS5+Gg9HaAA79gNh1AIPtCqhzejcIZ3lPzXQ==", + "dev": true, + "dependencies": { + "@types/geojson": "*" + } + }, "node_modules/@types/node": { "version": "20.17.57", "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.57.tgz", diff --git a/package.json b/package.json index af4798b..cab244c 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "devDependencies": { "@eslint/eslintrc": "^3", "@tailwindcss/postcss": "^4", + "@types/leaflet": "^1.9.18", "@types/node": "^20", "@types/react": "^19", "@types/react-dom": "^19", diff --git a/src/app/[...not_found]/layout.tsx b/src/app/[...not_found]/layout.tsx new file mode 100644 index 0000000..2fec109 --- /dev/null +++ b/src/app/[...not_found]/layout.tsx @@ -0,0 +1,35 @@ +import '@/app/globals.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; + let messages; + try { + messages = (await import(`../../../messages/${locale}.json`)).default; + } catch (error) { + notFound(); + } + + return ( + + + + {children} + + + + ); +} diff --git a/src/app/[...not_found]/page.tsx b/src/app/[...not_found]/page.tsx index 7802305..8b96a88 100644 --- a/src/app/[...not_found]/page.tsx +++ b/src/app/[...not_found]/page.tsx @@ -13,7 +13,7 @@ export default async function NotFound({ const routes = routeFactory(t, params.locale); return ( -
+

{t('pages_notFound_title')}

diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index 4cfb0ff..8f65972 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -18,15 +18,13 @@ export default async function RootLayout({ 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; + messages = (await import(`../../../messages/${locale}.json`)).default; + console.log('locale'); + console.log(locale); } catch (error) { - console.log(error); - notFound(); } diff --git a/src/assets/constants/footerMenu/index.ts b/src/assets/constants/footerMenu/index.ts index 5f88dbf..9c25c34 100644 --- a/src/assets/constants/footerMenu/index.ts +++ b/src/assets/constants/footerMenu/index.ts @@ -5,7 +5,7 @@ import { useParams } from 'next/navigation'; import { getQuickLinks } from '@/assets/constants/footerMenu/quickLinks.const'; import { getWhoAreWeLinks } from './whoAreWe.const'; -import { TLocales } from '@/locales/translates'; +import { TLocales } from '@/models/layout'; export default function FooterMenu() { const t = useTranslations(); diff --git a/src/assets/constants/footerMenu/quickLinks.const.ts b/src/assets/constants/footerMenu/quickLinks.const.ts index 4f483b4..b9e328b 100644 --- a/src/assets/constants/footerMenu/quickLinks.const.ts +++ b/src/assets/constants/footerMenu/quickLinks.const.ts @@ -1,7 +1,8 @@ import routeFactory from '../routeFactory'; -export function getQuickLinks(t: (key: string) => string, locale: string) { +export function getQuickLinks(t: any, locale: string) { const routes = routeFactory(t, locale); + return [ { title: routes.home.title, diff --git a/src/assets/constants/footerMenu/whoAreWe.const.ts b/src/assets/constants/footerMenu/whoAreWe.const.ts index c66c8b5..a240016 100644 --- a/src/assets/constants/footerMenu/whoAreWe.const.ts +++ b/src/assets/constants/footerMenu/whoAreWe.const.ts @@ -1,6 +1,6 @@ import routeFactory from '../routeFactory'; -export function getWhoAreWeLinks(t: (key: string) => string, locale: string) { +export function getWhoAreWeLinks(t: any, locale: string) { const routes = routeFactory(t, locale); return [ { diff --git a/src/components/layout/footer/Footer.tsx b/src/components/layout/footer/Footer.tsx index acea285..4894683 100644 --- a/src/components/layout/footer/Footer.tsx +++ b/src/components/layout/footer/Footer.tsx @@ -10,12 +10,12 @@ import { useTranslations } from 'next-intl'; import { useParams } from 'next/navigation'; import { getQuickLinks } from '@/assets/constants/footerMenu/quickLinks.const'; import { getWhoAreWeLinks } from '@/assets/constants/footerMenu/whoAreWe.const'; -import { TLocales } from '@/locales/translates'; +import { TLocales } from '@/models/layout'; export default function Footer() { const t = useTranslations(); const params = useParams(); - const locale = params.locale as TLocales; + const locale = (params.locale as TLocales) || 'en'; const quickLinks = getQuickLinks(t, locale); const whoAreWeLinks = getWhoAreWeLinks(t, locale); diff --git a/src/components/layout/footer/FooterInfo.tsx b/src/components/layout/footer/FooterInfo.tsx index 6f5b81f..dca7faf 100644 --- a/src/components/layout/footer/FooterInfo.tsx +++ b/src/components/layout/footer/FooterInfo.tsx @@ -6,6 +6,7 @@ import { Icon, IconName } from '@/components/uikit/icons'; import Image from 'next/image'; import Link from 'next/link'; import { useTranslations } from 'next-intl'; +import LanguageSwitch from '../languageSwitch'; export default function FooterInfo({ withLogo, @@ -42,6 +43,7 @@ export default function FooterInfo({ ))}
+
); } diff --git a/src/components/layout/languageSwitch/index.tsx b/src/components/layout/languageSwitch/index.tsx new file mode 100644 index 0000000..41841d9 --- /dev/null +++ b/src/components/layout/languageSwitch/index.tsx @@ -0,0 +1,28 @@ +'use client'; + +import Link from 'next/link'; +import { usePathname } from 'next/navigation'; + +export default function LanguageSwitch() { + const pathname = usePathname(); + + const pathWithoutLocale = pathname.replace(/^\/(en|fa)/, ''); + + return ( +
+ + EN + + | + + FA + +
+ ); +} diff --git a/src/components/layout/map/index.tsx b/src/components/layout/map/index.tsx index a9045e8..d5119d1 100644 --- a/src/components/layout/map/index.tsx +++ b/src/components/layout/map/index.tsx @@ -3,6 +3,7 @@ import { MapContainer, TileLayer, Marker, Popup } from 'react-leaflet'; import L from 'leaflet'; import 'leaflet/dist/leaflet.css'; +import 'leaflet/dist/leaflet.css'; delete (L.Icon.Default.prototype as any)._getIconUrl; L.Icon.Default.mergeOptions({ @@ -30,7 +31,7 @@ const ContactMap = () => { url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" /> - lastminute.com London Eye + Pasargad Bricks diff --git a/src/components/pages/home/Products.tsx b/src/components/pages/home/Products.tsx index 9763939..6aa7418 100644 --- a/src/components/pages/home/Products.tsx +++ b/src/components/pages/home/Products.tsx @@ -6,7 +6,7 @@ import Link from 'next/link'; import routeFactory from '@/assets/constants/routeFactory'; import { getTranslations } from 'next-intl/server'; import { ILayoutLocaleParams } from '@/models/layout'; -import { TLocales } from '@/locales/translates'; +import { TLocales } from '@/models/layout'; interface Props { locale: TLocales; diff --git a/src/locales/en.ts b/src/locales/en.ts deleted file mode 100644 index 8e7b637..0000000 --- a/src/locales/en.ts +++ /dev/null @@ -1,97 +0,0 @@ -const en = { - 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_notFound_title: '404 Not Found Page', - pages_notFound_description: 'You can either head back to the Homepage or try a search.', - pages_notFound_button:"Go To Home", - 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. ', - -com_contact_touch_title: 'Get in touch', -com_contact_touch_title_bold: 'with us', -com_contact_touch_description: 'Reach out for any inquiries, support, or to discuss how we can meet your industrial needs.', -com_contact_touch_option_1:'Contact', -com_contact_touch_option_2:'E-mail', -com_contact_touch_option_3:'Our Address', -com_contact_touch_option_3_description:'37 San Juan Lane Graaf Florisstraat 22A,3021 CH', -com_contact_title: 'Contact ', -com_contact_title_bold: 'me', -com_contact_first_name: 'Enter first name', -com_contact_last_name: 'Enter last name', -com_contact_email: 'Enter your e-mail', -com_contact_phone: 'Enter your phone no.', -com_contact_textarea: 'Write Message', - 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', - - // Home Page Components - 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', - - // Products Page Components - 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 }: { count: number }) => - `${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 Industry -The 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: ({ title }: { title: string }) => - `Products of ${title} Category`, -}; - -export default en; diff --git a/src/locales/fa.ts b/src/locales/fa.ts deleted file mode 100644 index 159db20..0000000 --- a/src/locales/fa.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { Translates } from './translates'; - -const fa = { - pages_home_title: 'صفحه‌ی اصلی', - pages_home_description: 'Welcome to the home page', - pages_about_title: 'About Us', - pages_about_description: 'Learn more about us on this page', - pages_notFound_title: '404 Not Found Page', - pages_notFound_description: 'You can either head back to the Homepage or try a search.', - pages_notFound_button:"Go To Home", - pages_contact_title: 'Contact Us', - pages_product_categories_title: 'Product', - pages_blog_title: 'Blog', - pages_projects_title: 'Project', - 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: 'اطلاعات بیشتر', - com_home_Banner_link1: ' Advanced Manufacturing Solutions', - com_home_Banner_link2: 'Quality Assurance Systems', - com_home_Banner_link3: 'State-of-the-Art Technology', - com_contact_touch_title: 'Get in touch', -com_contact_touch_title_bold: 'with us', -com_contact_touch_description: 'Reach out for any inquiries, support, or to discuss how we can meet your industrial needs.', -com_contact_touch_option_1:'Contact', -com_contact_touch_option_2:'E-mail', -com_contact_touch_option_3:'Our Address', -com_contact_touch_option_3_description:'37 San Juan Lane Graaf Florisstraat 22A,3021 CH', -com_contact_title: 'Contact ', -com_contact_title_bold: 'me', -com_contact_first_name: 'Enter first name', -com_contact_last_name: 'Enter last name', -com_contact_email: 'Enter your e-mail', -com_contact_phone: 'Enter your phone no.', -com_contact_textarea: 'Write Message', -} as Translates; - -export default fa; diff --git a/src/locales/translates.ts b/src/locales/translates.ts deleted file mode 100644 index 5fe47e4..0000000 --- a/src/locales/translates.ts +++ /dev/null @@ -1,69 +0,0 @@ -import en from './en'; -import fa from './fa'; - -// Universal getCookie function -export function getCookie(name: string): string | undefined { - if (typeof window !== 'undefined') { - // Client-side - const match = document.cookie.match( - new RegExp('(^| )' + name + '=([^;]+)'), - ); - return match ? decodeURIComponent(match[2]) : undefined; - } else { - // Server-side (Next.js App Router) - try { - // Dynamically import to avoid errors in client bundle - const { cookies } = require('next/headers'); - return cookies().get(name)?.value; - } catch { - return undefined; - } - } -} - -// Universal setCookie function to change language -export function changeLanguage(lang: TLocales, days = 365) { - if (typeof window !== 'undefined') { - // Client-side - const expires = new Date(Date.now() + days * 864e5).toUTCString(); - document.cookie = `lang=${encodeURIComponent(lang)}; expires=${expires}; path=/`; - } else { - // Server-side (Next.js App Router) - try { - const { cookies } = require('next/headers'); - cookies().set('lang', lang, { path: '/', maxAge: days * 24 * 60 * 60 }); - } catch { - // No-op on server if not available - } - } -} - -export const locales = { - en: en as unknown as Translates, - fa, -} as Record; - -export const translates = ( - key: keyof Translates, - dynamicValue?: Record, -): string | ((dynamicValue: Record) => string) => { - const lang = (getCookie('lang') || 'en') as TLocales; - const value = locales[lang][key] || locales.en[key] || key; - if (typeof value === 'function') { - return value(dynamicValue || {}); - } - return value; -}; - -export const t = ( - key: keyof Translates, - dynamicValue?: Record, -) => ''; - -export type TLocales = 'en' | 'fa'; - -export type Translates = { - [K in keyof typeof en]: - | string - | ((dynamicValue: Record) => string); -}; diff --git a/src/models/layout.d.ts b/src/models/layout.d.ts index 526e0c8..a021256 100644 --- a/src/models/layout.d.ts +++ b/src/models/layout.d.ts @@ -1,3 +1,5 @@ export interface ILayoutLocaleParams { locale: TLocales; } + +export type TLocales = 'en' | 'fa'; From 929960b26f77f90635370138abeea1ff0387d916 Mon Sep 17 00:00:00 2001 From: ahasani194 Date: Sun, 8 Jun 2025 10:05:37 +0330 Subject: [PATCH 2/4] Add Vazirmatn font files and CSS definitions for multiple font weights --- messages/fa.json | 2 +- src/app/[locale]/layout.tsx | 6 +- src/app/globals.css | 117 ++---------------- src/assets/constants/routeFactory/index.ts | 2 +- src/assets/fonts/manrope/manrope.css | 104 ++++++++++++++++ .../fonts/vazir/Vazirmatn-FD-Black.woff2 | Bin 0 -> 49100 bytes .../fonts/vazir/Vazirmatn-FD-Bold.woff2 | Bin 0 -> 49868 bytes .../fonts/vazir/Vazirmatn-FD-ExtraBold.woff2 | Bin 0 -> 49628 bytes .../fonts/vazir/Vazirmatn-FD-ExtraLight.woff2 | Bin 0 -> 49816 bytes .../fonts/vazir/Vazirmatn-FD-Light.woff2 | Bin 0 -> 49712 bytes .../fonts/vazir/Vazirmatn-FD-Medium.woff2 | Bin 0 -> 49784 bytes .../fonts/vazir/Vazirmatn-FD-Regular.woff2 | Bin 0 -> 49044 bytes .../fonts/vazir/Vazirmatn-FD-SemiBold.woff2 | Bin 0 -> 49608 bytes .../fonts/vazir/Vazirmatn-FD-Thin.woff2 | Bin 0 -> 49556 bytes src/assets/fonts/vazir/vazir.css | 63 ++++++++++ 15 files changed, 182 insertions(+), 112 deletions(-) create mode 100644 src/assets/fonts/manrope/manrope.css create mode 100644 src/assets/fonts/vazir/Vazirmatn-FD-Black.woff2 create mode 100644 src/assets/fonts/vazir/Vazirmatn-FD-Bold.woff2 create mode 100644 src/assets/fonts/vazir/Vazirmatn-FD-ExtraBold.woff2 create mode 100644 src/assets/fonts/vazir/Vazirmatn-FD-ExtraLight.woff2 create mode 100644 src/assets/fonts/vazir/Vazirmatn-FD-Light.woff2 create mode 100644 src/assets/fonts/vazir/Vazirmatn-FD-Medium.woff2 create mode 100644 src/assets/fonts/vazir/Vazirmatn-FD-Regular.woff2 create mode 100644 src/assets/fonts/vazir/Vazirmatn-FD-SemiBold.woff2 create mode 100644 src/assets/fonts/vazir/Vazirmatn-FD-Thin.woff2 create mode 100644 src/assets/fonts/vazir/vazir.css diff --git a/messages/fa.json b/messages/fa.json index 7493c64..2e98cc5 100644 --- a/messages/fa.json +++ b/messages/fa.json @@ -50,7 +50,7 @@ "com_products_category_Ghermez_title": "قرمز", "com_products_category_Semirom_title": "سمیرم", "com_products_category_Zard_title": "زرد", - "com_products_category_types_count": "تعداد نوع", + "com_products_category_types_count": "تعداد محصولات {count}", "com_products_category_show_all_CTA": "نمایش محصولات", "pages_products_content_title": "طبقه‌بندی آجر: درک تنوع و کاربردها", "pages_products_content_description": "آجرها به عنوان یکی از قدیمی‌ترین و پرکاربردترین مصالح ساختمانی بشر، در طول تاریخ دچار تحول زیادی شده‌اند. امروزه این مصالح در طیف بسیار متنوعی تولید و عرضه می‌شوند و به مهندسان و معماران این امکان را می‌دهند تا مناسب‌ترین آجر را برای هر پروژه و نیازی، از سازه‌های سنتی و تاریخی تا ساختمان‌های مدرن و پیشرفته، انتخاب کنند. برای درک بهتر این تنوع، می‌توان آجرها را بر اساس چند معیار کلیدی طبقه‌بندی کرد که هر یک ویژگی‌ها و کاربردهای خاص خود را دارند.\n۱. طبقه‌بندی بر اساس روش تولید: از سنت تا صنعت پیشرفته\nروش تولید آجرها مستقیماً بر ظاهر، بافت و ویژگی‌های آن‌ها تأثیر می‌گذارد.\nآجرهای دستی/قالبی: این آجرها با فشار دادن دستی خاک رس در قالب تولید می‌شوند. نتیجه، آجری با بافت نسبتاً زبر، لبه‌های نامنظم و ظاهری سنتی‌تر است که هر قطعه حس منحصر به فردی دارد. این نوع آجر اغلب برای پروژه‌های مرمت یا ساخت ساختمان‌هایی با سبک روستایی یا قدیمی استفاده می‌شود.\nآجرهای ماشینی: این آجرها با استفاده از ماشین‌آلات صنعتی تولید می‌شوند که دقت ابعادی و یکنواختی ظاهری بسیار بالاتری دارند. آجرهای ماشینی خود به دو دسته اصلی تقسیم می‌شوند:\nآجرهای سوراخ‌دار/توخالی: این آجرها دارای سوراخ‌هایی هستند که چندین مزیت دارند: کاهش وزن ساختمان، بهبود عایق حرارتی و صوتی و افزایش چسبندگی ملات.\nآجرهای توپر: این آجرها بدون سوراخ بوده و مقاومت فشاری بسیار بالایی دارند. آن‌ها برای سازه‌های باربر و دیوارهایی که به حداکثر استحکام نیاز دارند، ایده‌آل هستند.\n۲. طبقه‌بندی بر اساس نوع و ترکیب مواد اولیه: از خاک رس تا بتن\nجنس آجر تعیین‌کننده ویژگی‌های فیزیکی و شیمیایی آن است.", diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx index 8f65972..8f5dea9 100644 --- a/src/app/[locale]/layout.tsx +++ b/src/app/[locale]/layout.tsx @@ -19,18 +19,18 @@ export default async function RootLayout({ }>) { const locale = params.locale; + const fontClass = locale === 'fa' ? 'font-fa' : 'font-en'; + let messages; try { messages = (await import(`../../../messages/${locale}.json`)).default; - console.log('locale'); - console.log(locale); } catch (error) { notFound(); } return ( - + {children}