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])) }; ---