From cc7178f994ddbd7eca5cd50dbab49068a1492973 Mon Sep 17 00:00:00 2001 From: Juan Denis Date: Thu, 20 Aug 2026 22:00:40 -0400 Subject: [PATCH] =?UTF-8?q?fix(i18n):=20address=20Copilot=20review=20?= =?UTF-8?q?=E2=80=94=20render=20keyed=20labels,=20un-split=20sentences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - QuickCreate menu items carried labelKey but rendered item.label - DataTable and the ColumnsMenu/GroupMenu/SortMenu/SortChipBar helpers rendered column.header while 66 files declare headerKey; all now resolve through translateLabel when the header is a string - ExtensionBoundary failure card glued 'The extension' + slug + 'could not be loaded' from two fragments; now one Trans key with a component slot so translators can reorder - LogFileList/IconReferenceTab empty states split 'No matches for "' around the query; now single keys with a {{query}} placeholder es.json synced: orphans pruned, changed keys retranslated. --- frontend/src/components/QuickCreate.jsx | 3 ++- frontend/src/components/ds/ColumnsMenu.jsx | 3 ++- frontend/src/components/ds/DataTable.jsx | 3 ++- frontend/src/components/ds/GroupMenu.jsx | 3 ++- frontend/src/components/ds/SortChipBar.jsx | 3 ++- frontend/src/components/ds/SortMenu.jsx | 3 ++- frontend/src/components/log-viewer/LogFileList.jsx | 2 +- .../src/components/settings/IconReferenceTab.jsx | 2 +- frontend/src/i18n/locales/en.json | 7 +++---- frontend/src/i18n/locales/es.json | 7 +++---- frontend/src/plugins/runtime/ExtensionBoundary.jsx | 12 ++++++++++-- 11 files changed, 30 insertions(+), 18 deletions(-) diff --git a/frontend/src/components/QuickCreate.jsx b/frontend/src/components/QuickCreate.jsx index 1e5e421a..4719a842 100644 --- a/frontend/src/components/QuickCreate.jsx +++ b/frontend/src/components/QuickCreate.jsx @@ -10,6 +10,7 @@ import { } from '@/components/ui/dropdown-menu'; import { cn } from '@/lib/utils'; import { useTranslation } from 'react-i18next'; +import { translateLabel } from '../i18n/labels'; // Global quick-create (the CRM "+" button). One entry point for every "new // thing" flow, wherever you are. Route-based flows navigate directly; flows @@ -54,7 +55,7 @@ export function QuickCreate({ className, variant = 'icon' }) { {CREATE_ITEMS.map((item) => ( navigate(item.path)}> ))} diff --git a/frontend/src/components/ds/ColumnsMenu.jsx b/frontend/src/components/ds/ColumnsMenu.jsx index e4440dc5..8ff7a75a 100644 --- a/frontend/src/components/ds/ColumnsMenu.jsx +++ b/frontend/src/components/ds/ColumnsMenu.jsx @@ -3,6 +3,7 @@ import { Button } from '@/components/ui/button'; import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'; import { cn } from '@/lib/utils'; import { useTranslation } from 'react-i18next'; +import { translateLabel } from '../../i18n/labels'; // Toolbar popover for column show/hide (datatables.net "column visibility" // button). Lists every hideable column with an eye toggle; the trigger shows @@ -16,7 +17,7 @@ export function ColumnsMenu({ columns = [], hiddenKeys = [], onToggle, onShowAll const { t } = useTranslation(); const hideable = columns.filter((c) => c.hideable !== false); const labelFor = (column) => ( - typeof column.header === 'string' && column.header ? column.header : column.key + typeof column.header === 'string' && column.header ? translateLabel(t, column, 'header') : column.key ); return ( diff --git a/frontend/src/components/ds/DataTable.jsx b/frontend/src/components/ds/DataTable.jsx index 6fa208e8..21a3f3e6 100644 --- a/frontend/src/components/ds/DataTable.jsx +++ b/frontend/src/components/ds/DataTable.jsx @@ -16,6 +16,7 @@ import EmptyState from '../EmptyState'; import ColumnMenu from './grid/ColumnMenu'; import { applyFilters, isDecorative, withInferredTypes } from './grid/fields'; import { useTranslation } from 'react-i18next'; +import { translateLabel } from '../../i18n/labels'; /** * Declarative data table built on top of the shadcn/ui Table primitives. @@ -407,7 +408,7 @@ export function DataTable({ } > - {column.header} + {typeof column.header === 'string' ? translateLabel(t, column, 'header') : column.header} {canSort && ( {isSorted && sorts[sortIndex].direction === 'asc' ? ( diff --git a/frontend/src/components/ds/GroupMenu.jsx b/frontend/src/components/ds/GroupMenu.jsx index 93ee8e50..e8044e50 100644 --- a/frontend/src/components/ds/GroupMenu.jsx +++ b/frontend/src/components/ds/GroupMenu.jsx @@ -3,6 +3,7 @@ import { Button } from '@/components/ui/button'; import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'; import { cn } from '@/lib/utils'; import { useTranslation } from 'react-i18next'; +import { translateLabel } from '../../i18n/labels'; // Toolbar popover for row grouping (Huly/Frappe "Group by"). Lists the // table's groupable columns plus "No grouping"; the trigger shows the active @@ -15,7 +16,7 @@ export function GroupMenu({ columns = [], groupBy = null, onChange, className }) if (!groupable.length) return null; const labelFor = (column) => ( - typeof column.header === 'string' && column.header ? column.header : column.key + typeof column.header === 'string' && column.header ? translateLabel(t, column, 'header') : column.key ); const active = groupable.find((c) => c.key === groupBy); diff --git a/frontend/src/components/ds/SortChipBar.jsx b/frontend/src/components/ds/SortChipBar.jsx index 4128f69d..9df6b98a 100644 --- a/frontend/src/components/ds/SortChipBar.jsx +++ b/frontend/src/components/ds/SortChipBar.jsx @@ -1,6 +1,7 @@ import { ArrowUp, ArrowDown, X } from 'lucide-react'; import { cn } from '@/lib/utils'; import { useTranslation } from 'react-i18next'; +import { translateLabel } from '../../i18n/labels'; // Active-sort chip bar (Twenty's EditableSortChip pattern). Renders one chip // per sort level above the table: click the chip body to flip direction, ✕ to @@ -16,7 +17,7 @@ export function SortChipBar({ columns = [], sorts = [], onChange, className }) { const labelFor = (key) => { const column = columns.find((c) => c.key === key); if (!column) return key; - return typeof column.header === 'string' && column.header ? column.header : column.key; + return typeof column.header === 'string' && column.header ? translateLabel(t, column, 'header') : column.key; }; const flip = (key) => onChange?.( diff --git a/frontend/src/components/ds/SortMenu.jsx b/frontend/src/components/ds/SortMenu.jsx index 7058e3db..430887b1 100644 --- a/frontend/src/components/ds/SortMenu.jsx +++ b/frontend/src/components/ds/SortMenu.jsx @@ -3,6 +3,7 @@ import { Button } from '@/components/ui/button'; import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'; import { cn } from '@/lib/utils'; import { useTranslation } from 'react-i18next'; +import { translateLabel } from '../../i18n/labels'; // Toolbar popover for user-controllable multi-column sorting (Frappe CRM // style). Each active sort is a row: field label, asc/desc toggle, remove. @@ -18,7 +19,7 @@ export function SortMenu({ columns = [], sorts = [], onChange, className }) { const column = sortableColumns.find((c) => c.key === key); if (!column) return key; // Column headers may be React nodes; only plain text makes a usable label. - return typeof column.header === 'string' ? column.header : column.key; + return typeof column.header === 'string' ? translateLabel(t, column, 'header') : column.key; }; const flip = (key) => onChange?.( diff --git a/frontend/src/components/log-viewer/LogFileList.jsx b/frontend/src/components/log-viewer/LogFileList.jsx index ec446fcf..c9b741f9 100644 --- a/frontend/src/components/log-viewer/LogFileList.jsx +++ b/frontend/src/components/log-viewer/LogFileList.jsx @@ -77,7 +77,7 @@ export default function LogFileList({ files, selectedPath, onSelect, onRefresh, ) : groups.length === 0 ? (
-

{t('app.logFileList.noMatchesFor', 'No matches for "')}{query}".

+

{t('app.logFileList.noMatchesFor', 'No matches for "{{query}}".', { query })}

) : ( groups.map((group) => { diff --git a/frontend/src/components/settings/IconReferenceTab.jsx b/frontend/src/components/settings/IconReferenceTab.jsx index c07f8563..d78da58e 100644 --- a/frontend/src/components/settings/IconReferenceTab.jsx +++ b/frontend/src/components/settings/IconReferenceTab.jsx @@ -125,7 +125,7 @@ const IconReferenceTab = () => { {Object.keys(filteredCatalog).length === 0 && (
-

{t('app.iconReferenceTab.noIconsMatch', 'No icons match "')}{searchQuery}"

+

{t('app.iconReferenceTab.noIconsMatch', 'No icons match "{{query}}"', { query: searchQuery })}

)} diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json index 9129bff8..24dd706d 100644 --- a/frontend/src/i18n/locales/en.json +++ b/frontend/src/i18n/locales/en.json @@ -2565,10 +2565,9 @@ "when": "When" }, "extensionBoundary": { - "couldNotBeLoaded": "could not be loaded", "extensionCrashed": "Extension crashed", "itsOtherPagesAndTheRest": "Its other pages and the rest of the panel are unaffected. Try reinstalling or updating it from the Marketplace.", - "theExtension": "The extension" + "theExtensionCouldNotBeLoaded": "The extension <0>{{slug}} could not be loaded" }, "extensionPermissionsDialog": { "blocked": "Blocked", @@ -3454,7 +3453,7 @@ "iconReference": "Icon Reference", "iconsClickAnIconNameTo": "icons). Click an icon name to copy it.", "lucideReactIconsAvailableInThe": "Lucide React icons available in the project (", - "noIconsMatch": "No icons match \"", + "noIconsMatch": "No icons match \"{{query}}\"", "searchIcons": "Search icons..." }, "imagesTab": { @@ -3791,7 +3790,7 @@ "logFileList": { "filterLogFiles": "Filter log files…", "noLogFilesFound": "No log files found.", - "noMatchesFor": "No matches for \"", + "noMatchesFor": "No matches for \"{{query}}\".", "reloadList": "Reload list" }, "logHelpers": { diff --git a/frontend/src/i18n/locales/es.json b/frontend/src/i18n/locales/es.json index fd8a5ef5..bf6b69b6 100644 --- a/frontend/src/i18n/locales/es.json +++ b/frontend/src/i18n/locales/es.json @@ -2565,10 +2565,9 @@ "when": "Cuándo" }, "extensionBoundary": { - "couldNotBeLoaded": "no se pudo cargar", "extensionCrashed": "La extensión falló", "itsOtherPagesAndTheRest": "Sus otras páginas y el resto del panel no se ven afectados. Prueba a reinstalarla o actualizarla desde el Marketplace.", - "theExtension": "La extensión" + "theExtensionCouldNotBeLoaded": "La extensión <0>{{slug}} no se pudo cargar" }, "extensionPermissionsDialog": { "blocked": "Bloqueado", @@ -3454,7 +3453,7 @@ "iconReference": "Referencia de iconos", "iconsClickAnIconNameTo": "iconos). Haz clic en el nombre de un icono para copiarlo.", "lucideReactIconsAvailableInThe": "Iconos de Lucide React disponibles en el proyecto (", - "noIconsMatch": "Ningún icono coincide con \"", + "noIconsMatch": "Ningún icono coincide con \"{{query}}\"", "searchIcons": "Buscar iconos..." }, "imagesTab": { @@ -3791,7 +3790,7 @@ "logFileList": { "filterLogFiles": "Filtrar archivos de registro…", "noLogFilesFound": "No se encontraron archivos de registro.", - "noMatchesFor": "Sin coincidencias para \"", + "noMatchesFor": "No hay coincidencias para \"{{query}}\".", "reloadList": "Recargar lista" }, "logHelpers": { diff --git a/frontend/src/plugins/runtime/ExtensionBoundary.jsx b/frontend/src/plugins/runtime/ExtensionBoundary.jsx index 9bedf845..61a13e9c 100644 --- a/frontend/src/plugins/runtime/ExtensionBoundary.jsx +++ b/frontend/src/plugins/runtime/ExtensionBoundary.jsx @@ -9,7 +9,7 @@ * `getRuntimeLoadState`, with the error string in a popover (plan 32 #5). */ import { Component } from 'react'; -import { useTranslation } from 'react-i18next'; +import { Trans, useTranslation } from 'react-i18next'; import { t } from '../../i18n/t'; // Plain (dependency-free) card so it renders even if the SDK/design-system is @@ -24,7 +24,15 @@ export function ExtensionFailureCard({ slug, title, message }) { {title || 'Extension failed to load'}

- {t('app.extensionBoundary.theExtension', 'The extension')} {slug} {t('app.extensionBoundary.couldNotBeLoaded', 'could not be loaded')} + {/* One key with a component slot, not prefix/suffix + fragments: split sentences cannot be reordered by a + translator. */} + ]} + /> {message ? ': ' : '.'} {message && {message}}