Przeglądaj źródła

fix(i18n): localize health subscore labels and unknown OUI manufacturer (#779)

Map the canonical Spanish strings coming from the backend health score
("Servicios" subscore chip) and the OUI fallback ("Desconocido") to the
active language via i18n helpers, following the existing healthLabel
pattern. Also widen the subscore label column so the text no longer
overlaps the bar.

Co-authored-by: gnacho <hnacho@proton.me>
Nacho 2 miesięcy temu
rodzic
commit
f5feac6fc6

+ 9 - 2
app/public/locales/en/translation.json

@@ -272,7 +272,13 @@
       "critical": "Critical",
       "excellent": "Excellent",
       "good": "Good",
-      "warning": "Warning"
+      "warning": "Warning",
+      "subscores": {
+        "wan": "WAN",
+        "wifi": "Wi-Fi",
+        "infra": "Infra",
+        "services": "Services"
+      }
     },
     "active": "Active",
     "unknown": "Unknown",
@@ -433,7 +439,8 @@
       "tv": "TV"
     },
     "wiredConnection": "Wired connection",
-    "weakChip": "{{count}} with weak signal"
+    "weakChip": "{{count}} with weak signal",
+    "unknownManufacturer": "Unknown"
   },
   "home": {
     "devices": "Clients",

+ 9 - 2
app/public/locales/es/translation.json

@@ -272,7 +272,13 @@
       "critical": "Crítico",
       "excellent": "Excelente",
       "good": "Bueno",
-      "warning": "Atención"
+      "warning": "Atención",
+      "subscores": {
+        "wan": "WAN",
+        "wifi": "Wi-Fi",
+        "infra": "Infra",
+        "services": "Servicios"
+      }
     },
     "active": "Activo",
     "unknown": "Desconocido",
@@ -433,7 +439,8 @@
       "tv": "TV"
     },
     "wiredConnection": "Conexión por cable",
-    "weakChip": "{{count}} con señal débil"
+    "weakChip": "{{count}} con señal débil",
+    "unknownManufacturer": "Desconocido"
   },
   "home": {
     "devices": "Clientes",

+ 2 - 1
app/src/components/routers/RouterClients.tsx

@@ -2,6 +2,7 @@ import { useMemo, useState } from 'react'
 import { motion, useReducedMotion } from 'framer-motion'
 import { ArrowDown, ArrowUp, ArrowUpDown } from 'lucide-react'
 import { useTranslation } from 'react-i18next'
+import { manufacturerLabel } from '@/i18n'
 import type { Router } from '@/data/mock'
 import { fmtEs } from '@/data/mock'
 import { useNetPulse } from '@/data/DataProvider'
@@ -107,7 +108,7 @@ export function RouterClients({ router }: { router: Router }) {
                       </span>
                       <div>
                         <div className="font-medium text-text-primary" translate="no">{d.name}</div>
-                        <div className="text-caption text-text-muted">{d.manufacturer}</div>
+                        <div className="text-caption text-text-muted">{manufacturerLabel(d.manufacturer)}</div>
                       </div>
                     </div>
                   </td>

+ 2 - 2
app/src/components/topology/TopologyMap.tsx

@@ -12,7 +12,7 @@ import { useNavigate } from 'react-router'
 import { animate, motion, useReducedMotion } from 'framer-motion'
 import { Cloud, Laptop, Router as RouterIcon, Server, Smartphone, Tag } from 'lucide-react'
 import { useTranslation } from 'react-i18next'
-import { relTime } from '@/i18n'
+import { manufacturerLabel, relTime } from '@/i18n'
 import type { Device, DistributionNode, Router, WanInfo, WGPeer } from '@/data/mock'
 import { fmtEs } from '@/data/mock'
 import { StatusPill } from '@/components/StatusPill'
@@ -324,7 +324,7 @@ function ChipTooltip({
         />
       </div>
       <div className="mt-0.5 font-mono text-caption text-text-muted">
-        {d.manufacturer} · {d.mac}
+        {manufacturerLabel(d.manufacturer)} · {d.mac}
       </div>
       <div className="mt-2 space-y-1.5">
         {/* Conexión + IP en una horizontal; la IP no se trunca (issue #149) */}

+ 12 - 0
app/src/i18n.ts

@@ -135,6 +135,18 @@ export function healthLabel(label: string): string {
   return k ? i18n.t(`common.health.${k}`) : label
 }
 
+/** Subscore de salud por clave ("wan" | "wifi" | "infra" | "services") → idioma activo */
+export function subscoreLabel(key: string, label: string): string {
+  const known = ['wan', 'wifi', 'infra', 'services']
+  return known.includes(key) ? i18n.t(`common.health.subscores.${key}`) : label
+}
+
+/** Fabricante OUI canónico del dataset ("Desconocido" = sin match) → idioma activo */
+export function manufacturerLabel(manufacturer: string): string {
+  if (manufacturer === 'Desconocido') return i18n.t('devices.unknownManufacturer')
+  return manufacturer
+}
+
 /** Rol canónico del dataset ("Principal" | "AP") → idioma activo */
 export function roleLabel(role: string): string {
   if (role === 'Principal') return i18n.t('common.rolePrimary')

+ 4 - 4
app/src/pages/Devices.tsx

@@ -37,7 +37,7 @@ import {
 } from '@/components/ui/dropdown-menu'
 import { Input } from '@/components/ui/input'
 import { Switch } from '@/components/ui/switch'
-import { dhcpLease, numLocale } from '@/i18n'
+import { dhcpLease, manufacturerLabel, numLocale } from '@/i18n'
 import { fmtEs, signalLevel } from '@/data/mock'
 import { useNetPulse } from '@/data/DataProvider'
 import { useDashboard } from '@/hooks/useDashboard'
@@ -583,7 +583,7 @@ function DeviceDetail({
       </DetailItem>
       <DetailItem label={t('devices.detail.dhcpLease')}>{dhcpLease(device.dhcpLease)}</DetailItem>
       <DetailItem label={t('devices.detail.firstSeen')}>{device.firstSeen}</DetailItem>
-      <DetailItem label={t('devices.detail.manufacturer')}>{device.manufacturer}</DetailItem>
+      <DetailItem label={t('devices.detail.manufacturer')}>{manufacturerLabel(device.manufacturer)}</DetailItem>
       <DetailItem label="Hostname" mono>
         {device.hostname}
       </DetailItem>
@@ -835,7 +835,7 @@ function ListRow({
               <TypeBadge type={device.type} className="lg:hidden" />
               {!device.online && <StatusPill tone="muted" label={t('common.status.offline')} />}
             </div>
-            <div className="truncate text-caption text-text-muted">{device.manufacturer}</div>
+            <div className="truncate text-caption text-text-muted">{manufacturerLabel(device.manufacturer)}</div>
           </div>
         </div>
         {/* Tipo */}
@@ -983,7 +983,7 @@ function GridCard({
           <TypeBadge type={device.type} />
         </div>
         <div className="truncate text-caption text-text-muted">
-          {device.manufacturer} · <span className="font-mono">{device.ip}</span>
+          {manufacturerLabel(device.manufacturer)} · <span className="font-mono">{device.ip}</span>
         </div>
         <div className="mt-2.5 flex flex-wrap items-center gap-1.5">
           <RouterChipLink routerId={device.routerId} onNavigate={onNavigateRouter} />

+ 3 - 3
app/src/sections/HeroStrip.tsx

@@ -3,7 +3,7 @@ import { Fragment, useEffect, useState } from 'react'
 import { AlertTriangle, CheckCircle2, Gauge, MonitorSmartphone } from 'lucide-react'
 import { useTranslation } from 'react-i18next'
 import { cn } from '@/lib/utils'
-import { healthLabel } from '@/i18n'
+import { healthLabel, subscoreLabel } from '@/i18n'
 import { CountUp } from '@/components/CountUp'
 import { HealthRing } from '@/components/HealthRing'
 import { StatusPill } from '@/components/StatusPill'
@@ -156,8 +156,8 @@ export function HeroStrip() {
             <div className="mt-2 grid w-full max-w-xs grid-cols-2 gap-x-4 gap-y-1.5">
               {healthScore.subscores.map((s) => (
                 <div key={s.key} className="flex items-center gap-2">
-                  <span className="w-12 text-right text-[10px] font-medium uppercase tracking-wider text-text-muted">
-                    {s.label}
+                  <span className="w-14 shrink-0 truncate text-right text-[10px] font-medium uppercase tracking-wider text-text-muted">
+                    {subscoreLabel(s.key, s.label)}
                   </span>
                   <div className="relative h-1.5 flex-1 overflow-hidden rounded-full bg-border">
                     <div