Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion en/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
<!-- Lien vers la même page dans l'autre langue (app.js y ajoute l'ancre
courante au clic). Zone générée par scripts/generate-static.js. -->
<!-- static:langToggle -->
<a id="langToggle" class="btn" href="/" hreflang="fr" lang="fr" aria-label="undefined">FR</a>
<a id="langToggle" class="btn" href="/" hreflang="fr" lang="fr" aria-label="Passer en français">FR</a>
<!-- /static:langToggle -->
<button id="focusToggle" class="btn icon-btn" type="button" aria-pressed="false" data-i18n-aria="nav.focusToggle" aria-label="Focus mode" title="Focus mode">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
Expand Down
2 changes: 1 addition & 1 deletion en/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<!-- Lien vers la même page dans l'autre langue (results.js y ajoute
l'ancre courante au clic). Zone générée par scripts/generate-static.js. -->
<!-- static:langToggle -->
<a id="langToggle" class="btn" href="/results.html" hreflang="fr" lang="fr" aria-label="undefined">FR</a>
<a id="langToggle" class="btn" href="/results.html" hreflang="fr" lang="fr" aria-label="Passer en français">FR</a>
<!-- /static:langToggle -->
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
<!-- Lien vers la même page dans l'autre langue (app.js y ajoute l'ancre
courante au clic). Zone générée par scripts/generate-static.js. -->
<!-- static:langToggle -->
<a id="langToggle" class="btn" href="/en/" hreflang="en" lang="en" aria-label="undefined">EN</a>
<a id="langToggle" class="btn" href="/en/" hreflang="en" lang="en" aria-label="Switch to English">EN</a>
<!-- /static:langToggle -->
<button id="focusToggle" class="btn icon-btn" type="button" aria-pressed="false" data-i18n-aria="nav.focusToggle" aria-label="Focus lecture" title="Focus lecture">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
Expand Down
2 changes: 1 addition & 1 deletion results.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
<!-- Lien vers la même page dans l'autre langue (results.js y ajoute
l'ancre courante au clic). Zone générée par scripts/generate-static.js. -->
<!-- static:langToggle -->
<a id="langToggle" class="btn" href="/en/results.html" hreflang="en" lang="en" aria-label="undefined">EN</a>
<a id="langToggle" class="btn" href="/en/results.html" hreflang="en" lang="en" aria-label="Switch to English">EN</a>
<!-- /static:langToggle -->
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions scripts/check-seo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ async function lot1(browser) {
const { page } = await openTracked(jsCtx, from + hash);
const link = await page.evaluate(() => {
const a = document.getElementById("langToggle");
return a ? { tag: a.tagName, hreflang: a.getAttribute("hreflang"), lang: a.getAttribute("lang"), href: a.getAttribute("href") } : null;
return a ? { tag: a.tagName, hreflang: a.getAttribute("hreflang"), lang: a.getAttribute("lang"), href: a.getAttribute("href"), label: a.getAttribute("aria-label") } : null;
});
let arrived = "";
if (link && link.tag === "A") {
Expand All @@ -423,7 +423,9 @@ async function lot1(browser) {
}
await page.close();
const other = from.startsWith("/en/") ? "fr" : "en";
check(1, "1.7", `lien de langue ${from + hash} → ${to} (<a hreflang="${other}" lang="${other}">)`, link && link.tag === "A" && link.hreflang === other && link.lang === other && arrived === to, link ? `<${link.tag.toLowerCase()} href="${link.href}" hreflang=${link.hreflang} lang=${link.lang}> → ${arrived}` : "pas de #langToggle");
// Libellé accessible dans la langue de la cible (nav.langToggleLabel).
const label = other === "en" ? "Switch to English" : "Passer en français";
check(1, "1.7", `lien de langue ${from + hash} → ${to} (<a hreflang="${other}" lang="${other}" aria-label="${label}">)`, link && link.tag === "A" && link.hreflang === other && link.lang === other && link.label === label && arrived === to, link ? `<${link.tag.toLowerCase()} href="${link.href}" hreflang=${link.hreflang} lang=${link.lang} aria-label="${link.label}"> → ${arrived}` : "pas de #langToggle");
}

// Critère 8 — liens internes dans la langue de la page (rendu avec JS).
Expand Down
4 changes: 3 additions & 1 deletion scripts/generate-static.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ function langLinksHtml(page, lang) {
// langue de sa cible (hreflang, lang). Le libellé accessible vient d'i18n.js.
function langToggleHtml(page, lang, dict) {
const other = lang === "fr" ? "en" : "fr";
if (!dict["nav.langToggleLabel"]) throw new Error(`${page.out[lang]} : libellé nav.langToggleLabel introuvable dans i18n.js`);
const href = new URL(page.urls[other]).pathname;
return `<a id="langToggle" class="btn" href="${href}" hreflang="${other}" lang="${other}" aria-label="${escapeAttr(dict["nav.langToggleLabel"])}">${other.toUpperCase()}</a>`;
}
Expand Down Expand Up @@ -380,7 +381,8 @@ function englishShell(frHtml, file) {

for (const page of PAGES) {
const template = fs.readFileSync(path.join(ROOT, page.template), "utf8");
const keys = i18nKeys(template);
// + le libellé du lien FR/EN, que le gabarit ne cite pas (zone calculée).
const keys = [...i18nKeys(template), "nav.langToggleLabel"];

const fr = await renderPage(browser, page, "fr", { slug: slugs[0], keys });
const frOut = applyRender(template, page, "fr", fr);
Expand Down
Loading