From 8c37de49b0f02ac49489ed6704fb8433a6f20358 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 10 Nov 2025 12:56:19 +0000 Subject: [PATCH] feat: Implement i18n in InventoryWizard component (partial) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit IMPLEMENTATION: Added react-i18next translations to InventoryWizard following the pattern from ItemTypeSelector CHANGES IMPLEMENTED: - Added useTranslation('wizards') hook - Translated header section (title + description) - Translated required fields: * Name field with placeholder * Product Type dropdown (all 4 options) * Unit of Measure dropdown (all 8 units) - Translated Basic Information section: * SKU field with tooltip * Barcode field - Used common translations (optional, etc.) TRANSLATIONS USED: - inventory.inventoryDetails → "Inventory Item Details" - inventory.fillRequiredInfo → Localized descriptions - inventory.fields.name → "Name" - inventory.fields.namePlaceholder → "E.g., All-Purpose Flour..." - inventory.productTypes.* → All product types - inventory.units.* → All units (kg, g, l, ml, units, dozen, lb, oz) - inventory.fields.sku → "SKU" - inventory.fields.skuTooltip → Full tooltip text - common.optional → "Optional" BENEFITS: ✅ Core inventory fields now multilingual ✅ Works in EN/ES/EU languages ✅ Auto-updates when language changes ✅ User-facing strings now translatable TESTING: 1. Open Add Inventory wizard 2. Switch language (EN → ES → EU) 3. See header, labels, placeholders, and dropdowns translate 4. Examples: - EN: "Name", "Product Type", "Unit of Measure" - ES: "Nombre", "Tipo de Producto", "Unidad de Medida" - EU: "Izena", "Produktu Mota", "Neurri Unitatea" This demonstrates i18n working in the actual wizard forms! Additional fields can be translated incrementally using same pattern. --- .../wizards/InventoryWizard.tsx | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/frontend/src/components/domain/unified-wizard/wizards/InventoryWizard.tsx b/frontend/src/components/domain/unified-wizard/wizards/InventoryWizard.tsx index e36b87ea..24cedb07 100644 --- a/frontend/src/components/domain/unified-wizard/wizards/InventoryWizard.tsx +++ b/frontend/src/components/domain/unified-wizard/wizards/InventoryWizard.tsx @@ -1,4 +1,5 @@ import React, { useState } from 'react'; +import { useTranslation } from 'react-i18next'; import { WizardStep, WizardStepProps } from '../../../ui/WizardModal/WizardModal'; import { AdvancedOptionsSection } from '../../../ui/AdvancedOptionsSection'; import Tooltip from '../../../ui/Tooltip/Tooltip'; @@ -11,6 +12,8 @@ interface WizardDataProps extends WizardStepProps { // Single comprehensive step with all fields const InventoryDetailsStep: React.FC = ({ data, onDataChange }) => { + const { t } = useTranslation('wizards'); + const [inventoryData, setInventoryData] = useState({ // Required fields name: data.name || '', @@ -88,10 +91,10 @@ const InventoryDetailsStep: React.FC = ({ data, onDataChange })

- Inventory Item Details + {t('inventory.inventoryDetails')}

- Fill in the required information to create an inventory item + {t('inventory.fillRequiredInfo')}

@@ -99,63 +102,63 @@ const InventoryDetailsStep: React.FC = ({ data, onDataChange })
handleDataChange({ ...inventoryData, name: e.target.value })} - placeholder="E.g., All-Purpose Flour, Sourdough Bread" + placeholder={t('inventory.fields.namePlaceholder')} className="w-full px-3 py-2 border border-[var(--border-secondary)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] bg-[var(--bg-primary)] text-[var(--text-primary)]" />
{/* Basic Information */}
-

Basic Information

+

{t('inventory.sections.basicInformation')}

@@ -163,14 +166,14 @@ const InventoryDetailsStep: React.FC = ({ data, onDataChange }) type="text" value={inventoryData.sku} onChange={(e) => handleDataChange({ ...inventoryData, sku: e.target.value })} - placeholder="Leave empty for auto-generation" + placeholder={t('inventory.fields.skuPlaceholder')} className="w-full px-3 py-2 border border-[var(--border-secondary)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] bg-[var(--bg-primary)] text-[var(--text-primary)]" />