feat: Add i18n support for AI insights with structured reasoning

Complete i18n implementation for internal service reasoning:
- Update AIInsight interface to include reasoning_data field
- Integrate useReasoningTranslation hook in AI Insights page
- Add translation keys for safety stock, price forecaster, and optimization

Translation coverage (EN/ES/EU):
- Safety Stock: statistical z-score, advanced variability, fixed percentage, errors
- Price Forecaster: price change predictions, volatility alerts, buying recommendations
- Optimization: EOQ calculations, MOQ/max constraints, tier pricing

Benefits:
- AI insights now display in user's preferred language
- Consistent with PO/Batch reasoning translation pattern
- Structured parameters enable rich, contextualized translations
- Falls back gracefully to description field if translation missing

Implementation:
- frontend/src/api/services/aiInsights.ts: Add reasoning_data to interface
- frontend/src/pages/app/analytics/ai-insights/AIInsightsPage.tsx: Translate insights
- frontend/src/locales/*/reasoning.json: Add safetyStock, priceForecaster, optimization keys

This completes the full i18n implementation for the bakery AI system.
This commit is contained in:
Claude
2025-11-07 19:25:08 +00:00
parent 9d284cae46
commit 5dacb939c9
5 changed files with 103 additions and 1 deletions

View File

@@ -25,6 +25,11 @@ export interface AIInsight {
category: 'demand' | 'procurement' | 'inventory' | 'production' | 'sales' | 'system' | 'business';
title: string;
description: string;
reasoning_data?: {
type: string;
parameters: Record<string, any>;
[key: string]: any;
};
impact_type: 'cost_savings' | 'waste_reduction' | 'yield_improvement' | 'revenue' | 'system_health' | 'process_improvement';
impact_value?: number;
impact_unit?: string;