Skip to content

Commit 498ab8b

Browse files
Copilothotlong
andcommitted
fix: use i18n translation keys for all hardcoded strings in DashboardEditor and PageCanvasEditor
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent f5ea6a8 commit 498ab8b

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

packages/plugin-designer/src/DashboardEditor.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,14 @@ function WidgetPropertyPanel({
204204
onChange,
205205
onClose,
206206
}: WidgetPropertyPanelProps) {
207+
const { t } = useDesignerTranslation();
207208
return (
208209
<div
209210
data-testid="widget-property-panel"
210211
className="w-72 shrink-0 space-y-4 rounded-lg border border-gray-200 bg-white p-4"
211212
>
212213
<div className="flex items-center justify-between">
213-
<h4 className="text-sm font-semibold text-gray-800">Widget Properties</h4>
214+
<h4 className="text-sm font-semibold text-gray-800">{t('appDesigner.widgetProperties')}</h4>
214215
<button
215216
type="button"
216217
onClick={onClose}
@@ -325,10 +326,10 @@ function WidgetPropertyPanel({
325326

326327
{/* Widget size */}
327328
<div className="space-y-1">
328-
<label className="text-xs font-medium text-gray-600">Layout Size</label>
329+
<label className="text-xs font-medium text-gray-600">{t('appDesigner.widgetLayoutSize')}</label>
329330
<div className="flex gap-2">
330331
<div className="flex-1">
331-
<label htmlFor="widget-width" className="text-[10px] text-gray-400">Width</label>
332+
<label htmlFor="widget-width" className="text-[10px] text-gray-400">{t('appDesigner.widgetWidth')}</label>
332333
<input
333334
id="widget-width"
334335
data-testid="widget-prop-width"
@@ -341,7 +342,7 @@ function WidgetPropertyPanel({
341342
/>
342343
</div>
343344
<div className="flex-1">
344-
<label htmlFor="widget-height" className="text-[10px] text-gray-400">Height</label>
345+
<label htmlFor="widget-height" className="text-[10px] text-gray-400">{t('appDesigner.widgetHeight')}</label>
345346
<input
346347
id="widget-height"
347348
data-testid="widget-prop-height"
@@ -364,12 +365,13 @@ function WidgetPropertyPanel({
364365
// ============================================================================
365366

366367
function DashboardPreview({ schema }: { schema: DashboardSchema }) {
368+
const { t } = useDesignerTranslation();
367369
const widgets = schema.widgets || [];
368370
return (
369371
<div data-testid="dashboard-preview" className="rounded-lg border border-gray-200 bg-gray-50 p-4">
370-
<h4 className="mb-3 text-sm font-semibold text-gray-700">{schema.title || 'Dashboard Preview'}</h4>
372+
<h4 className="mb-3 text-sm font-semibold text-gray-700">{schema.title || t('appDesigner.dashboardPreview')}</h4>
371373
{widgets.length === 0 ? (
372-
<div className="text-xs text-gray-400">No widgets to preview</div>
374+
<div className="text-xs text-gray-400">{t('appDesigner.noWidgetsPreview')}</div>
373375
) : (
374376
<div
375377
className="grid gap-2"
@@ -599,7 +601,7 @@ export function DashboardEditor({
599601
onClick={undo}
600602
disabled={!canUndo}
601603
className="rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30"
602-
aria-label="Undo"
604+
aria-label={t('appDesigner.undo')}
603605
>
604606
<Undo2 className="h-4 w-4" />
605607
</button>
@@ -609,7 +611,7 @@ export function DashboardEditor({
609611
onClick={redo}
610612
disabled={!canRedo}
611613
className="rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30"
612-
aria-label="Redo"
614+
aria-label={t('appDesigner.redo')}
613615
>
614616
<Redo2 className="h-4 w-4" />
615617
</button>
@@ -655,7 +657,7 @@ export function DashboardEditor({
655657
<DashboardPreview schema={currentSchema} />
656658
) : widgets.length === 0 ? (
657659
<div className="flex h-48 items-center justify-center rounded-lg border-2 border-dashed border-gray-200 text-sm text-gray-400">
658-
No widgets. Click a button above to add one.
660+
{t('appDesigner.noWidgets')}
659661
</div>
660662
) : (
661663
<div

packages/plugin-designer/src/PageCanvasEditor.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ const COMPONENT_PALETTE = [
9696
];
9797

9898
const MODE_TABS = [
99-
{ value: 'page', label: 'Page' },
100-
{ value: 'dashboard', label: 'Dashboard' },
99+
{ value: 'page', labelKey: 'appDesigner.modePage' },
100+
{ value: 'dashboard', labelKey: 'appDesigner.modeDashboard' },
101101
] as const;
102102

103103
type CanvasMode = (typeof MODE_TABS)[number]['value'];
@@ -206,13 +206,14 @@ function ComponentPropertyPanel({
206206
onChange,
207207
onClose,
208208
}: ComponentPropertyPanelProps) {
209+
const { t } = useDesignerTranslation();
209210
return (
210211
<div
211212
data-testid="component-property-panel"
212213
className="w-64 shrink-0 space-y-4 rounded-lg border border-gray-200 bg-white p-4"
213214
>
214215
<div className="flex items-center justify-between">
215-
<h4 className="text-sm font-semibold text-gray-800">Component Properties</h4>
216+
<h4 className="text-sm font-semibold text-gray-800">{t('appDesigner.componentProperties')}</h4>
216217
<button
217218
type="button"
218219
onClick={onClose}
@@ -261,11 +262,12 @@ function ComponentPropertyPanel({
261262
// ============================================================================
262263

263264
function PagePreview({ schema, components }: { schema: PageSchema; components: CanvasComponent[] }) {
265+
const { t } = useDesignerTranslation();
264266
return (
265267
<div data-testid="page-preview" className="rounded-lg border border-gray-200 bg-gray-50 p-4">
266-
<h4 className="mb-3 text-sm font-semibold text-gray-700">{schema.title || 'Page Preview'}</h4>
268+
<h4 className="mb-3 text-sm font-semibold text-gray-700">{schema.title || t('appDesigner.pagePreview')}</h4>
267269
{components.length === 0 ? (
268-
<div className="text-xs text-gray-400">No components to preview</div>
270+
<div className="text-xs text-gray-400">{t('appDesigner.noComponentsPreview')}</div>
269271
) : (
270272
<div className="space-y-2">
271273
{components.map((comp) => {
@@ -502,7 +504,7 @@ export function PageCanvasEditor({
502504
: 'text-gray-500 hover:text-gray-700'
503505
)}
504506
>
505-
{tab.label}
507+
{t(tab.labelKey)}
506508
</button>
507509
))}
508510
</div>
@@ -536,7 +538,7 @@ export function PageCanvasEditor({
536538
onClick={undo}
537539
disabled={!canUndo}
538540
className="rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30"
539-
aria-label="Undo"
541+
aria-label={t('appDesigner.undo')}
540542
>
541543
<Undo2 className="h-4 w-4" />
542544
</button>
@@ -546,7 +548,7 @@ export function PageCanvasEditor({
546548
onClick={redo}
547549
disabled={!canRedo}
548550
className="rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30"
549-
aria-label="Redo"
551+
aria-label={t('appDesigner.redo')}
550552
>
551553
<Redo2 className="h-4 w-4" />
552554
</button>
@@ -592,7 +594,7 @@ export function PageCanvasEditor({
592594
<PagePreview schema={schema} components={components} />
593595
) : components.length === 0 ? (
594596
<div className="flex h-48 items-center justify-center rounded-lg border-2 border-dashed border-gray-200 text-sm text-gray-400">
595-
Empty page. Click a button above to add a component.
597+
{t('appDesigner.emptyPage')}
596598
</div>
597599
) : (
598600
<div className="space-y-2">

0 commit comments

Comments
 (0)