feat: ajoute le système i18n frontend (FR/EN)

- Crée js/i18n/i18n.js : module central avec t(), getLocale(), setLocale()
- Crée js/i18n/locales/fr.json et en.json : traductions FR et EN
- Crée js/i18n/applyTranslations.js : applique les data-i18n au DOM
- Crée js/i18n/langSwitcher.js : sélecteur de langue (boutons FR/EN)
- Modifie index.html : ajoute les attributs data-i18n sur tous les textes
- Modifie js/main.js : intègre i18n et relance l'application des traductions
- Modifie css/form.css : styles pour le sélecteur de langue
- Persistance de la langue dans localStorage (clé cv_lang)
This commit is contained in:
stanig2106
2026-04-05 22:43:44 +01:00
parent f0cf9a605f
commit 4e9746c308
8 changed files with 173 additions and 9 deletions
+13 -1
View File
@@ -3,6 +3,9 @@ import { collectCompetences, renderCompetences } from './sections/competences.js
import { collectFormation, renderFormation } from './sections/formation.js';
import { collectExperience, renderExperience } from './sections/experience.js';
import { collectHobbies, renderHobbies } from './sections/hobbies.js';
import { t, getLocale } from './i18n/i18n.js';
import { applyTranslations } from './i18n/applyTranslations.js';
import { initLangSwitcher } from './i18n/langSwitcher.js';
function generateCV() {
const identite = collectIdentite();
@@ -19,12 +22,21 @@ function generateCV() {
const success = document.getElementById('success');
if (success) {
success.textContent = `CV prêt à être généré pour ${identite.prenom} ${identite.nom} !`;
success.textContent = t('success', { prenom: identite.prenom, nom: identite.nom });
success.style.display = 'block';
}
}
document.addEventListener('DOMContentLoaded', () => {
document.documentElement.lang = getLocale();
applyTranslations();
initLangSwitcher();
document.addEventListener('localechange', () => {
applyTranslations();
initLangSwitcher();
});
document.getElementById('cv-form')?.addEventListener('submit', (e) => {
e.preventDefault();
generateCV();