import type { Locale } from "./i18n"; /** * Groupes de pages traduites. * Chaque groupe contient les URLs correspondantes pour chaque langue. */ const translationGroups: Record[] = [ { fr: "/", en: "/en", ar: "/ar" }, { fr: "/a-propos", en: "/en/about", ar: "/ar/نبذة-عني" }, { fr: "/code", en: "/en/code", ar: "/ar/برمجة" }, { fr: "/theatre", en: "/en/acting", ar: "/ar/مسرح" }, { fr: "/photo", en: "/en/photo", ar: "/ar/تصوير" }, ]; /** Index inversé : pathname → groupe de traduction */ const pathIndex = new Map>(); for (const group of translationGroups) { for (const path of Object.values(group)) { pathIndex.set(path, group); } } /** * Retourne les URLs alternatives pour un pathname donné. * Les trailing slashes sont normalisés. */ export function getAlternateUrls( pathname: string, ): Record | undefined { const normalized = pathname.replace(/\/$/, "") || "/"; return pathIndex.get(normalized); }