From dc9239c38ebbeb403fc6a41a0a53238901671e7e Mon Sep 17 00:00:00 2001 From: Nicolas Fryder Date: Wed, 1 Jul 2026 20:51:39 +0200 Subject: [PATCH] =?UTF-8?q?fix(i18n):=20s=C3=A9lecteur=20langue=20sans=20e?= =?UTF-8?q?moji=20flags,=20d=C3=A9tection=20navigateur=20multi-lang,=20d?= =?UTF-8?q?=C3=A9faut=20anglais?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Options du select : noms natifs (Français, English, Deutsch…) à la place des emojis flags - detectLang() itère navigator.languages[] pour trouver la première langue supportée - Fallback sur "en" au lieu de "fr" si aucune langue connue - Fallback t() sur "en" au lieu de "fr" Co-Authored-By: Claude Sonnet 4.6 --- apps/web/site/app.js | 10 +++++++--- apps/web/site/index.html | 22 +++++++++++----------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/apps/web/site/app.js b/apps/web/site/app.js index 19f82dd..c9cf3a5 100644 --- a/apps/web/site/app.js +++ b/apps/web/site/app.js @@ -7,14 +7,18 @@ const API_BASE = "https://bm.nicolasfryder.ovh"; const SUPPORTED_LANGS = ["fr", "en", "de", "es", "it", "pl", "nl", "ro", "pt", "cs", "sv"]; function detectLang() { - const nav = (navigator.language || navigator.languages?.[0] || "fr").split("-")[0].toLowerCase(); - return SUPPORTED_LANGS.includes(nav) ? nav : "fr"; + const langs = navigator.languages?.length ? navigator.languages : [navigator.language || "en"]; + for (const l of langs) { + const code = l.split("-")[0].toLowerCase(); + if (SUPPORTED_LANGS.includes(code)) return code; + } + return "en"; } let currentLang = localStorage.getItem("lang") || detectLang(); function t(key) { - return window.LOCALES?.[currentLang]?.[key] ?? window.LOCALES?.["fr"]?.[key] ?? key; + return window.LOCALES?.[currentLang]?.[key] ?? window.LOCALES?.["en"]?.[key] ?? key; } function applyI18n() { diff --git a/apps/web/site/index.html b/apps/web/site/index.html index ade3f11..242afc8 100644 --- a/apps/web/site/index.html +++ b/apps/web/site/index.html @@ -42,17 +42,17 @@
Metal from Europe