Ver Fonte

fix(i18n): move language bootstrap to external script

Closes #2173
Nacho há 1 semana atrás
pai
commit
63f26fc919
3 ficheiros alterados com 13 adições e 13 exclusões
  1. 1 0
      CHANGELOG.md
  2. 0 13
      app/index.html
  3. 12 0
      app/public/boot.js

+ 1 - 0
CHANGELOG.md

@@ -14,6 +14,7 @@ y este proyecto se adhiere a [Versionado Semántico](https://semver.org/lang/es/
 
 ### Fixed
 
+- The early language choice now runs from the external `boot.js` instead of an inline script blocked by the production Content Security Policy (#2173).
 - The update history header no longer nests its download action inside another button. Expand/collapse and download are separate keyboard-accessible controls (#2168).
 - Devices named only by mDNS now use that hostname in the existing type rules, so a vacuum or console without a DHCP hostname no longer stays unknown (#2157).
 - Useful mDNS names now replace generated DHCP placeholders without overriding reservations, aliases or manual choices. The improved name and inferred type stay when mDNS temporarily disappears (#2159).

+ 0 - 13
app/index.html

@@ -2,19 +2,6 @@
 <html lang="en" class="dark">
   <head>
     <meta charset="UTF-8" />
-    <script>
-      // Set <html lang> before first paint from the saved choice, so the
-      // browser does not read the static lang="en" and offer to translate a
-      // page that is about to render in another language (#666).
-      (function () {
-        try {
-          var l = localStorage.getItem('netpulse-lang')
-          if (!l || l === 'auto') l = navigator.language || 'en'
-          l = l.slice(0, 2).toLowerCase()
-          document.documentElement.lang = l === 'zh' ? 'zh-CN' : l === 'es' ? 'es' : 'en'
-        } catch (e) {}
-      })()
-    </script>
     <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
     <meta name="theme-color" content="#070B12" />
     <meta name="description" content="NetPulse — panel de control de tu red doméstica" />

+ 12 - 0
app/public/boot.js

@@ -1,3 +1,15 @@
+// Set <html lang> before first paint from the saved choice, so the
+// browser does not read the static lang="en" and offer to translate a
+// page that is about to render in another language (#666).
+(function () {
+  try {
+    var l = localStorage.getItem('netpulse-lang')
+    if (!l || l === 'auto') l = navigator.language || 'en'
+    l = l.slice(0, 2).toLowerCase()
+    document.documentElement.lang = l === 'zh' ? 'zh-CN' : l === 'es' ? 'es' : 'en'
+  } catch (e) {}
+})()
+
 // Red de seguridad (bug pantalla negra tras update): si el bundle no
 // carga, #root queda vacío (el splash CSS pinta negro). Tras 8 s se
 // recarga UNA vez (guard en sessionStorage evita bucles); si vuelve a