From 3d23e84b34b3a5dece6f809b6135dfbd0e72e3a4 Mon Sep 17 00:00:00 2001 From: Jalil Arfaoui Date: Wed, 18 Feb 2026 14:14:00 +0100 Subject: [PATCH] =?UTF-8?q?Internationalisation=20compl=C3=A8te=20et=20ajo?= =?UTF-8?q?ut=20des=20pages=20code,=20th=C3=A9=C3=A2tre,=20acting=20(FR,?= =?UTF-8?q?=20EN,=20AR)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajout des pages code et théâtre/acting en FR, EN et AR. Création de vraies routes localisées /en/photo et /ar/تصوير au lieu du hack ?lang=. Extraction de composants partagés (PhotoHomeContent, PhotoBlogIndexContent, PhotoBlogPostContent, PhotoAlbumContent) pour éviter la duplication entre langues. Traduction des catégories photo (16 fichiers JSON), de la navigation, du footer et des aria-labels. Routes AR avec slugs arabes (/ar/تصوير/مدونة, /ar/تصوير/ألبومات). --- src/components/LanguageSwitcher.astro | 16 + src/components/header.astro | 12 +- src/components/logo.astro | 4 +- src/components/photo/AlbumHeader.astro | 6 +- src/components/photo/CategoryGrid.astro | 18 +- src/components/photo/CategoryNav.astro | 43 ++- src/components/photo/ExploreSection.astro | 28 +- src/components/photo/Lightbox.astro | 22 +- src/components/photo/PhotoFooter.astro | 16 +- src/components/photo/PhotoGallery.astro | 14 +- src/components/photo/SlideControls.astro | 11 +- src/components/photo/Slideshow.astro | 6 +- .../photo/pages/PhotoAlbumContent.astro | 25 ++ .../photo/pages/PhotoBlogIndexContent.astro | 338 ++++++++++++++++++ .../photo/pages/PhotoBlogPostContent.astro | 119 ++++++ .../photo/pages/PhotoHomeContent.astro | 21 ++ src/content/config.ts | 1 + src/content/photoCategories/cultures.ar.json | 6 + src/content/photoCategories/cultures.en.json | 6 + src/content/photoCategories/engines.ar.json | 6 + src/content/photoCategories/engines.en.json | 6 + src/content/photoCategories/everyday.ar.json | 6 + src/content/photoCategories/everyday.en.json | 6 + src/content/photoCategories/music.ar.json | 6 + src/content/photoCategories/music.en.json | 6 + src/content/photoCategories/nature.ar.json | 6 + src/content/photoCategories/nature.en.json | 6 + src/content/photoCategories/places.ar.json | 6 + src/content/photoCategories/places.en.json | 6 + src/content/photoCategories/portraits.ar.json | 6 + src/content/photoCategories/portraits.en.json | 6 + src/content/photoCategories/sports.ar.json | 6 + src/content/photoCategories/sports.en.json | 6 + src/layouts/PhotoLayout.astro | 13 +- src/pages/ar/index.astro | 4 +- src/pages/ar/برمجة.astro | 68 ++++ src/pages/ar/تصوير.astro | 5 + src/pages/ar/تصوير/ألبومات/[category].astro | 19 + src/pages/ar/تصوير/مدونة/[year]/[slug].astro | 24 ++ src/pages/ar/تصوير/مدونة/index.astro | 5 + src/pages/ar/مسرح.astro | 49 +++ src/pages/code.astro | 68 ++++ src/pages/en/acting.astro | 49 +++ src/pages/en/code.astro | 68 ++++ src/pages/en/index.astro | 4 +- src/pages/en/photo.astro | 5 + src/pages/en/photo/albums/[category].astro | 19 + src/pages/en/photo/blog/[year]/[slug].astro | 24 ++ src/pages/en/photo/blog/index.astro | 5 + src/pages/photo.astro | 13 +- src/pages/photo/albums/[...category].astro | 36 -- src/pages/photo/albums/[category].astro | 19 + src/pages/photo/blog/[year]/[slug].astro | 117 +----- src/pages/photo/blog/index.astro | 325 +---------------- src/pages/theatre.astro | 49 +++ src/utils/i18n.ts | 71 +++- 56 files changed, 1314 insertions(+), 541 deletions(-) create mode 100644 src/components/photo/pages/PhotoAlbumContent.astro create mode 100644 src/components/photo/pages/PhotoBlogIndexContent.astro create mode 100644 src/components/photo/pages/PhotoBlogPostContent.astro create mode 100644 src/components/photo/pages/PhotoHomeContent.astro create mode 100644 src/content/photoCategories/cultures.ar.json create mode 100644 src/content/photoCategories/cultures.en.json create mode 100644 src/content/photoCategories/engines.ar.json create mode 100644 src/content/photoCategories/engines.en.json create mode 100644 src/content/photoCategories/everyday.ar.json create mode 100644 src/content/photoCategories/everyday.en.json create mode 100644 src/content/photoCategories/music.ar.json create mode 100644 src/content/photoCategories/music.en.json create mode 100644 src/content/photoCategories/nature.ar.json create mode 100644 src/content/photoCategories/nature.en.json create mode 100644 src/content/photoCategories/places.ar.json create mode 100644 src/content/photoCategories/places.en.json create mode 100644 src/content/photoCategories/portraits.ar.json create mode 100644 src/content/photoCategories/portraits.en.json create mode 100644 src/content/photoCategories/sports.ar.json create mode 100644 src/content/photoCategories/sports.en.json create mode 100644 src/pages/ar/برمجة.astro create mode 100644 src/pages/ar/تصوير.astro create mode 100644 src/pages/ar/تصوير/ألبومات/[category].astro create mode 100644 src/pages/ar/تصوير/مدونة/[year]/[slug].astro create mode 100644 src/pages/ar/تصوير/مدونة/index.astro create mode 100644 src/pages/ar/مسرح.astro create mode 100644 src/pages/code.astro create mode 100644 src/pages/en/acting.astro create mode 100644 src/pages/en/code.astro create mode 100644 src/pages/en/photo.astro create mode 100644 src/pages/en/photo/albums/[category].astro create mode 100644 src/pages/en/photo/blog/[year]/[slug].astro create mode 100644 src/pages/en/photo/blog/index.astro delete mode 100644 src/pages/photo/albums/[...category].astro create mode 100644 src/pages/photo/albums/[category].astro create mode 100644 src/pages/theatre.astro diff --git a/src/components/LanguageSwitcher.astro b/src/components/LanguageSwitcher.astro index 09dfa73..4d901bf 100644 --- a/src/components/LanguageSwitcher.astro +++ b/src/components/LanguageSwitcher.astro @@ -16,6 +16,22 @@ const translations: Record> = { en: '/en/about', ar: '/ar/نبذة-عني' }, + // Photo + '/photo': { + fr: '/photo', + en: '/en/photo', + ar: '/ar/تصوير' + }, + '/en/photo': { + fr: '/photo', + en: '/en/photo', + ar: '/ar/تصوير' + }, + '/ar/تصوير': { + fr: '/photo', + en: '/en/photo', + ar: '/ar/تصوير' + }, // Page d'accueil '/': { fr: '/', diff --git a/src/components/header.astro b/src/components/header.astro index 5004323..6a9a952 100644 --- a/src/components/header.astro +++ b/src/components/header.astro @@ -1,22 +1,28 @@ --- import Logo from "../components/logo.astro"; -// Détection de la langue courante +// Détection de la langue courante par le path uniquement const pathname = Astro.url.pathname; const currentLang = pathname.startsWith('/en') ? 'en' : pathname.startsWith('/ar') ? 'ar' : 'fr'; // Menu localisé const menus = { fr: [ + { name: 'Code', url: '/code' }, + { name: 'Théâtre', url: '/theatre' }, { name: 'Photo', url: '/photo' }, { name: 'À propos', url: '/a-propos' } ], en: [ - { name: 'Photo', url: '/photo' }, + { name: 'Code', url: '/en/code' }, + { name: 'Acting', url: '/en/acting' }, + { name: 'Photo', url: '/en/photo' }, { name: 'About', url: '/en/about' } ], ar: [ - { name: 'صور', url: '/photo' }, + { name: 'برمجة', url: '/ar/برمجة' }, + { name: 'مسرح', url: '/ar/مسرح' }, + { name: 'صور', url: '/ar/تصوير' }, { name: 'نبذة عني', url: '/ar/نبذة-عني' } ] }; diff --git a/src/components/logo.astro b/src/components/logo.astro index f33083f..27f4e5b 100644 --- a/src/components/logo.astro +++ b/src/components/logo.astro @@ -2,12 +2,14 @@ import HomeIcon from "./icons/HomeIcon.astro"; const pathname = Astro.url.pathname; +const currentLang = pathname.startsWith('/en') ? 'en' : pathname.startsWith('/ar') ? 'ar' : 'fr'; const isHome = pathname === '/' || pathname === '/en' || pathname === '/en/' || pathname === '/ar' || pathname === '/ar/'; +const homeUrl = currentLang === 'en' ? '/en' : currentLang === 'ar' ? '/ar' : '/'; --- {!isHome && ( diff --git a/src/components/photo/AlbumHeader.astro b/src/components/photo/AlbumHeader.astro index 9b86945..cfde3a8 100644 --- a/src/components/photo/AlbumHeader.astro +++ b/src/components/photo/AlbumHeader.astro @@ -1,6 +1,7 @@ --- import { Picture } from 'astro:assets'; import HeroViewport from './HeroViewport.astro'; +import { getDateLocale, type Locale } from '../../utils/i18n'; interface Props { title: string; @@ -9,9 +10,10 @@ interface Props { tags?: string[]; coverImage?: ImageMetadata; scrollTarget?: string; + lang?: Locale; } -const { title, description, date, tags, coverImage, scrollTarget = '.info-section' } = Astro.props; +const { title, description, date, tags, coverImage, scrollTarget = '.info-section', lang = 'fr' } = Astro.props; --- {coverImage && ( @@ -24,7 +26,7 @@ const { title, description, date, tags, coverImage, scrollTarget = '.info-sectio {description &&

{description}

} {date && (
-

Fil Photo

-

Parcourir les séries chronologiques, reportages et histoires en images

- - Voir le fil +

{t('photo', 'photoFeed', lang)}

+

{t('photo', 'feedDescription', lang)}

+
+ {t('photo', 'viewFeed', lang)} diff --git a/src/components/photo/Lightbox.astro b/src/components/photo/Lightbox.astro index 3ff5bb6..c5b4ce7 100644 --- a/src/components/photo/Lightbox.astro +++ b/src/components/photo/Lightbox.astro @@ -1,45 +1,49 @@ --- import { getCollection } from 'astro:content'; +import { t, type Locale } from '../../utils/i18n'; interface Props { images: { src: string; alt: string; title?: string }[]; albumTitle?: string; showCategory?: boolean; category?: string; + lang?: Locale; } -const { images, albumTitle = '', showCategory = false, category = '' } = Astro.props; +const { images, albumTitle = '', showCategory = false, category = '', lang = 'fr' } = Astro.props; const imagesForJS = JSON.stringify(images); -// Construire les labels depuis la collection -const photoCategories = await getCollection('photoCategories'); +// Construire les labels depuis la collection filtrée par langue +const allCategories = await getCollection('photoCategories'); +const langCategories = allCategories.filter(c => (c.data.lang ?? 'fr') === lang); +const effectiveCategories = langCategories.length > 0 ? langCategories : allCategories.filter(c => (c.data.lang ?? 'fr') === 'fr'); const categoryLabels: Record = { - 'blog': 'Fil Photo', - ...Object.fromEntries(photoCategories.map(cat => [cat.id, cat.data.title])) + 'blog': t('photo', 'photoFeed', lang), + ...Object.fromEntries(effectiveCategories.map(cat => [cat.id.replace(/\.(en|ar)$/, ''), cat.data.title])) }; ---