deploy / deploy (push) Successful in 1m24s
rebuild the public site on the Next.js App Router with static export, per-section SEO pages, metadata, sitemap, robots and a generated OG image add full-screen scroll-snap regions, staged scroll reveals, a hash-free tab navigation with a sliding indicator and region-by-region menu scrolling replace the theme text toggle with animated sun/moon icons restructure the CRM API into config, middleware, models, routes, services and utils layers redesign the CRM shell with a single surface, tab rail, full-width blurred DataTable, record dialogs and mask-based icons update Docker/Nginx publishing, Makefile targets, shared UI polish and docs Co-authored-by: Gitea Actions <-[email protected]>
174 lines
5.8 KiB
TypeScript
174 lines
5.8 KiB
TypeScript
"use client";
|
|
|
|
import {
|
|
createContext,
|
|
useCallback,
|
|
useContext,
|
|
useEffect,
|
|
useMemo,
|
|
useState,
|
|
type ReactNode,
|
|
} from "react";
|
|
|
|
export type Lang = "fr" | "en";
|
|
|
|
/** Champ traduit : la vitrine est bilingue, chaque libellé porte ses deux versions. */
|
|
export interface Localized {
|
|
fr: string;
|
|
en: string;
|
|
}
|
|
|
|
const fr = {
|
|
"brand.name": "COHAISE",
|
|
"nav.services": "Services",
|
|
"nav.demos": "Démos",
|
|
"nav.stack": "Stack",
|
|
"nav.about": "À propos",
|
|
"nav.contact": "Contact",
|
|
"hero.tagline":
|
|
"Votre projet commence par une idée. Il prend vie avec CoHaiSe.",
|
|
"hero.subtitle":
|
|
"Développement web, applications mobiles et design UI/UX. Des outils modernes, rapides et pensés pour durer.",
|
|
"hero.primary": "Découvrir les services",
|
|
"hero.secondary": "Me contacter",
|
|
"services.title": "Services",
|
|
"services.subtitle": "Quatre façons de donner vie à votre idée.",
|
|
"demos.title": "Démos",
|
|
"demos.subtitle": "Des versions adaptées de réalisations concrètes.",
|
|
"demos.source": "Voir le code",
|
|
"stack.title": "Stack",
|
|
"stack.subtitle": "Les technologies qui font tourner mes projets.",
|
|
"about.title": "À propos",
|
|
"about.body":
|
|
"CoHaiSe développe des outils sur mesure : sites vitrines, applications mobiles et logiciels internes. Je conçois chaque projet pour qu'il soit rapide, maintenable et agréable à utiliser — de la première idée jusqu'à la mise en ligne, et après.",
|
|
"contact.title": "Contact",
|
|
"contact.subtitle": "Un projet en tête ? Parlons-en.",
|
|
"contact.firstName": "Prénom",
|
|
"contact.lastName": "Nom",
|
|
"contact.company": "Entreprise / organisme",
|
|
"contact.phone": "Téléphone (facultatif)",
|
|
"contact.email": "E-mail",
|
|
"contact.message": "Message",
|
|
"contact.submit": "Envoyer",
|
|
"contact.sending": "Envoi…",
|
|
"contact.success": "Merci ! Votre message a bien été envoyé.",
|
|
"contact.error": "Impossible d'envoyer le message. Réessayez plus tard.",
|
|
"footer.rights": "Tous droits réservés.",
|
|
"footer.built": "Conçu et développé par Esiah.",
|
|
"theme.light": "Mode clair",
|
|
"theme.dark": "Mode sombre",
|
|
} as const;
|
|
|
|
type MessageKey = keyof typeof fr;
|
|
|
|
const en: Record<MessageKey, string> = {
|
|
"brand.name": "COHAISE",
|
|
"nav.services": "Services",
|
|
"nav.demos": "Demos",
|
|
"nav.stack": "Stack",
|
|
"nav.about": "About",
|
|
"nav.contact": "Contact",
|
|
"hero.tagline":
|
|
"Your project starts with an idea. It comes to life with CoHaiSe.",
|
|
"hero.subtitle":
|
|
"Web development, mobile apps and UI/UX design. Modern, fast tools built to last.",
|
|
"hero.primary": "Discover the services",
|
|
"hero.secondary": "Contact me",
|
|
"services.title": "Services",
|
|
"services.subtitle": "Four ways to bring your idea to life.",
|
|
"demos.title": "Demos",
|
|
"demos.subtitle": "Adapted versions of real work.",
|
|
"demos.source": "View source",
|
|
"stack.title": "Stack",
|
|
"stack.subtitle": "The technologies behind my projects.",
|
|
"about.title": "About",
|
|
"about.body":
|
|
"CoHaiSe builds tailor-made tools: showcase sites, mobile apps and internal software. Every project is designed to be fast, maintainable and pleasant to use — from the first idea to launch, and beyond.",
|
|
"contact.title": "Contact",
|
|
"contact.subtitle": "Have a project in mind? Let's talk.",
|
|
"contact.firstName": "First name",
|
|
"contact.lastName": "Last name",
|
|
"contact.company": "Company / organization",
|
|
"contact.phone": "Phone (optional)",
|
|
"contact.email": "Email",
|
|
"contact.message": "Message",
|
|
"contact.submit": "Send",
|
|
"contact.sending": "Sending…",
|
|
"contact.success": "Thanks! Your message has been sent.",
|
|
"contact.error": "Could not send the message. Please try again later.",
|
|
"footer.rights": "All rights reserved.",
|
|
"footer.built": "Designed and built by Esiah.",
|
|
"theme.light": "Light mode",
|
|
"theme.dark": "Dark mode",
|
|
};
|
|
|
|
const dictionaries: Record<Lang, Record<MessageKey, string>> = { fr, en };
|
|
|
|
const STORAGE_KEY = "cohaise-lang";
|
|
|
|
const readStoredLang = (): Lang => {
|
|
try {
|
|
const stored = window.localStorage.getItem(STORAGE_KEY);
|
|
if (stored === "fr" || stored === "en") return stored;
|
|
if (window.navigator.language?.toLowerCase().startsWith("en")) return "en";
|
|
} catch {
|
|
// localStorage indisponible (navigation privée stricte, etc.)
|
|
}
|
|
return "fr";
|
|
};
|
|
|
|
interface LanguageContextValue {
|
|
lang: Lang;
|
|
setLang: (lang: Lang) => void;
|
|
t: (key: MessageKey) => string;
|
|
pick: (value: Localized) => string;
|
|
}
|
|
|
|
const LanguageContext = createContext<LanguageContextValue | null>(null);
|
|
|
|
export const LanguageProvider = ({ children }: { children: ReactNode }) => {
|
|
// Le premier rendu est toujours en français : il doit être identique côté
|
|
// serveur (export statique) et côté client pour éviter un mismatch
|
|
// d'hydratation. La préférence stockée est appliquée après le montage.
|
|
const [lang, setLangState] = useState<Lang>("fr");
|
|
|
|
useEffect(() => {
|
|
const next = readStoredLang();
|
|
setLangState((current) => (current === next ? current : next));
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
document.documentElement.lang = lang;
|
|
try {
|
|
window.localStorage.setItem(STORAGE_KEY, lang);
|
|
} catch {
|
|
// Écriture impossible : la langue reste valable pour la session.
|
|
}
|
|
}, [lang]);
|
|
|
|
const setLang = useCallback((next: Lang) => setLangState(next), []);
|
|
|
|
const value = useMemo<LanguageContextValue>(() => {
|
|
const dictionary = dictionaries[lang];
|
|
return {
|
|
lang,
|
|
setLang,
|
|
t: (key) => dictionary[key],
|
|
pick: (item) => item[lang],
|
|
};
|
|
}, [lang, setLang]);
|
|
|
|
return (
|
|
<LanguageContext.Provider value={value}>
|
|
{children}
|
|
</LanguageContext.Provider>
|
|
);
|
|
};
|
|
|
|
export const useLanguage = (): LanguageContextValue => {
|
|
const context = useContext(LanguageContext);
|
|
if (!context)
|
|
throw new Error("useLanguage doit être utilisé sous LanguageProvider.");
|
|
return context;
|
|
};
|