Files
bakery-ia/REASONING_I18N_AUDIT.md
Claude 84d38842ab feat: Implement complete i18n support for reasoning data
Created comprehensive multilingual translation system for JTBD dashboard
reasoning fields. Backend generates structured data, frontend translates
using i18n in EN, ES, and EU (Euskara).

Frontend Changes:
1. Created reasoning.json translation files (EN, ES, EU)
   - Purchase order reasoning types
   - Production batch reasoning types
   - Consequence translations
   - Severity levels
   - Error codes
   - All JTBD dashboard UI text

2. Created useReasoningTranslation hook
   - translatePOReasonng() - For purchase orders
   - translateBatchReasoning() - For production batches
   - translateConsequence() - For consequences
   - translateSeverity() - For severity levels
   - translateError() - For error codes
   - useReasoningFormatter() - Higher-level formatting

Translation Examples:
EN: "Low stock for Harinas del Norte. Stock runs out in 3 days."
ES: "Stock bajo para Harinas del Norte. Se agota en 3 días."
EU: "Harinas del Norte-rentzat stock baxua. 3 egunetan amaituko da."

Documentation:
- Created REASONING_I18N_AUDIT.md with full audit of hardcoded text
- Identified all files needing updates
- Documented strategy for backend error codes

Next Steps:
- Update dashboard components to use translations
- Fix demo seed scripts
- Fix backend services to return error codes
2025-11-07 18:24:38 +00:00

2.4 KiB

Reasoning i18n Audit Report

Files with Hardcoded English Reasoning Text

Already Fixed

  1. services/orchestrator/app/services/dashboard_service.py - Now returns reasoning_data
  2. services/procurement/app/services/procurement_service.py - Generates structured reasoning_data
  3. services/production/app/services/production_service.py - Generates structured reasoning_data

Needs Fixing

1. Demo Seed Scripts

File: services/procurement/scripts/demo/seed_demo_purchase_orders.py

  • Line 126: "Low stock detected for {supplier.name} items..."
  • Line 127: "Stock-out risk in {days_until_delivery + 2} days..."
  • Line 135: "Auto-approved based on supplier trust score..."

File: services/production/scripts/demo/seed_demo_batches.py

  • Similar hardcoded text (needs check)

Fix: Use create_po_reasoning_*() helper functions

2. Safety Stock Calculator

File: services/procurement/app/services/safety_stock_calculator.py

  • Line 111: 'Lead time or demand std dev is zero or negative'
  • Line 163: 'Insufficient historical demand data (need at least 2 data points)'

Fix: Return structured error codes instead of English text

3. Replenishment Planning Service

File: services/procurement/app/services/replenishment_planning_service.py

  • Line 376: 'Insufficient data for safety stock calculation'

Fix: Return structured error codes

4. ML Services

File: services/procurement/app/ml/price_forecaster.py

  • Needs audit for hardcoded reasoning text

5. Frontend Components

File: frontend/src/components/dashboard/OrchestrationSummaryCard.tsx

  • Hardcoded English text: "Last Night I Planned Your Day", "All caught up!", etc.

File: frontend/src/components/dashboard/HealthStatusCard.tsx

  • Hardcoded English text

File: frontend/src/components/dashboard/ActionQueueCard.tsx

  • Hardcoded English text: "What Needs Your Attention", "Why this is needed:", etc.

File: frontend/src/components/dashboard/ProductionTimelineCard.tsx

  • Hardcoded English text

File: frontend/src/components/dashboard/InsightsGrid.tsx

  • Uses backend labels (good) but needs i18n setup

Strategy

Backend

  • Return structured error codes: {"type": "error", "code": "INSUFFICIENT_DATA", "params": {...}}
  • Frontend translates based on code

Frontend

  • Setup react-i18next
  • Create translation files for EN, ES, CA
  • Update all dashboard components to use t() function