CRITICAL FIX: Translation keys showing instead of translated text
The Bug:
--------
Dashboard components were using useTranslation('reasoning') but the
'reasoning' namespace was NOT loaded into i18n configuration.
Result: i18n couldn't find translations and returned keys literally:
- "jtbd.health_status.last_updated" instead of "Last updated" / "Última actualización"
- "jtbd.action_queue.all_caught_up" instead of "All caught up!" / "¡Todo al día!"
- "jtbd.production_timeline.no_production" instead of translations
- etc.
Why It Happened:
----------------
locales/index.ts was missing:
1. Import statements for reasoning.json (all 3 languages)
2. 'reasoning' property in resources object (es/en/eu)
3. 'reasoning' in namespaces array
The Fix:
--------
Added to frontend/src/locales/index.ts:
1. Imports:
import reasoningEs from './es/reasoning.json';
import reasoningEn from './en/reasoning.json';
import reasoningEu from './eu/reasoning.json';
2. Resources object:
es: { ..., reasoning: reasoningEs }
en: { ..., reasoning: reasoningEn }
eu: { ..., reasoning: reasoningEu }
3. Namespaces array:
export const namespaces = [..., 'reasoning'] as const;
4. Exports:
export { ..., reasoningEs };
Now:
----
✅ t('jtbd.health_status.last_updated') returns "Last updated" (en) or "Última actualización" (es)
✅ All dashboard translations work in all 3 languages (es, en, eu)
✅ Language switching works properly
158 lines
5.0 KiB
TypeScript
158 lines
5.0 KiB
TypeScript
// Spanish translations
|
|
import commonEs from './es/common.json';
|
|
import authEs from './es/auth.json';
|
|
import inventoryEs from './es/inventory.json';
|
|
import foodSafetyEs from './es/foodSafety.json';
|
|
import suppliersEs from './es/suppliers.json';
|
|
import ordersEs from './es/orders.json';
|
|
import recipesEs from './es/recipes.json';
|
|
import errorsEs from './es/errors.json';
|
|
import dashboardEs from './es/dashboard.json';
|
|
import productionEs from './es/production.json';
|
|
import equipmentEs from './es/equipment.json';
|
|
import landingEs from './es/landing.json';
|
|
import settingsEs from './es/settings.json';
|
|
import ajustesEs from './es/ajustes.json';
|
|
import reasoningEs from './es/reasoning.json';
|
|
|
|
// English translations
|
|
import commonEn from './en/common.json';
|
|
import authEn from './en/auth.json';
|
|
import inventoryEn from './en/inventory.json';
|
|
import foodSafetyEn from './en/foodSafety.json';
|
|
import suppliersEn from './en/suppliers.json';
|
|
import ordersEn from './en/orders.json';
|
|
import recipesEn from './en/recipes.json';
|
|
import errorsEn from './en/errors.json';
|
|
import dashboardEn from './en/dashboard.json';
|
|
import productionEn from './en/production.json';
|
|
import equipmentEn from './en/equipment.json';
|
|
import landingEn from './en/landing.json';
|
|
import settingsEn from './en/settings.json';
|
|
import ajustesEn from './en/ajustes.json';
|
|
import reasoningEn from './en/reasoning.json';
|
|
|
|
// Basque translations
|
|
import commonEu from './eu/common.json';
|
|
import authEu from './eu/auth.json';
|
|
import inventoryEu from './eu/inventory.json';
|
|
import foodSafetyEu from './eu/foodSafety.json';
|
|
import suppliersEu from './eu/suppliers.json';
|
|
import ordersEu from './eu/orders.json';
|
|
import recipesEu from './eu/recipes.json';
|
|
import errorsEu from './eu/errors.json';
|
|
import dashboardEu from './eu/dashboard.json';
|
|
import productionEu from './eu/production.json';
|
|
import equipmentEu from './eu/equipment.json';
|
|
import landingEu from './eu/landing.json';
|
|
import settingsEu from './eu/settings.json';
|
|
import ajustesEu from './eu/ajustes.json';
|
|
import reasoningEu from './eu/reasoning.json';
|
|
|
|
// Translation resources by language
|
|
export const resources = {
|
|
es: {
|
|
common: commonEs,
|
|
auth: authEs,
|
|
inventory: inventoryEs,
|
|
foodSafety: foodSafetyEs,
|
|
suppliers: suppliersEs,
|
|
orders: ordersEs,
|
|
recipes: recipesEs,
|
|
errors: errorsEs,
|
|
dashboard: dashboardEs,
|
|
production: productionEs,
|
|
equipment: equipmentEs,
|
|
landing: landingEs,
|
|
settings: settingsEs,
|
|
ajustes: ajustesEs,
|
|
reasoning: reasoningEs,
|
|
},
|
|
en: {
|
|
common: commonEn,
|
|
auth: authEn,
|
|
inventory: inventoryEn,
|
|
foodSafety: foodSafetyEn,
|
|
suppliers: suppliersEn,
|
|
orders: ordersEn,
|
|
recipes: recipesEn,
|
|
errors: errorsEn,
|
|
dashboard: dashboardEn,
|
|
production: productionEn,
|
|
equipment: equipmentEn,
|
|
landing: landingEn,
|
|
settings: settingsEn,
|
|
ajustes: ajustesEn,
|
|
reasoning: reasoningEn,
|
|
},
|
|
eu: {
|
|
common: commonEu,
|
|
auth: authEu,
|
|
inventory: inventoryEu,
|
|
foodSafety: foodSafetyEu,
|
|
suppliers: suppliersEu,
|
|
orders: ordersEu,
|
|
recipes: recipesEu,
|
|
errors: errorsEu,
|
|
dashboard: dashboardEu,
|
|
production: productionEu,
|
|
equipment: equipmentEu,
|
|
landing: landingEu,
|
|
settings: settingsEu,
|
|
ajustes: ajustesEu,
|
|
reasoning: reasoningEu,
|
|
},
|
|
};
|
|
|
|
// Supported languages
|
|
export const supportedLanguages = ['es', 'en', 'eu'] as const;
|
|
export type SupportedLanguage = typeof supportedLanguages[number];
|
|
|
|
// Default language
|
|
export const defaultLanguage: SupportedLanguage = 'es';
|
|
|
|
// Language configuration
|
|
export const languageConfig = {
|
|
es: {
|
|
name: 'Español',
|
|
nativeName: 'Español',
|
|
code: 'es',
|
|
flag: 'es', // Using language code instead of flag for proper language identification
|
|
rtl: false,
|
|
},
|
|
en: {
|
|
name: 'English',
|
|
nativeName: 'English',
|
|
code: 'en',
|
|
flag: 'en', // Using language code instead of flag for proper language identification
|
|
rtl: false,
|
|
},
|
|
eu: {
|
|
name: 'Basque',
|
|
nativeName: 'Euskera',
|
|
code: 'eu',
|
|
flag: 'eu', // Using language code instead of flag for proper language identification
|
|
rtl: false,
|
|
},
|
|
};
|
|
|
|
// Namespaces available in translations
|
|
export const namespaces = ['common', 'auth', 'inventory', 'foodSafety', 'suppliers', 'orders', 'recipes', 'errors', 'dashboard', 'production', 'equipment', 'landing', 'settings', 'ajustes', 'reasoning'] as const;
|
|
export type Namespace = typeof namespaces[number];
|
|
|
|
// Helper function to get language display name
|
|
export const getLanguageDisplayName = (language: SupportedLanguage): string => {
|
|
return languageConfig[language]?.nativeName || language;
|
|
};
|
|
|
|
// Helper function to check if language is supported
|
|
export const isSupportedLanguage = (language: string): language is SupportedLanguage => {
|
|
return supportedLanguages.includes(language as SupportedLanguage);
|
|
};
|
|
|
|
// Export individual language modules for direct imports
|
|
export { commonEs, authEs, inventoryEs, foodSafetyEs, suppliersEs, ordersEs, recipesEs, errorsEs, equipmentEs, landingEs, settingsEs, ajustesEs, reasoningEs };
|
|
|
|
// Default export with all translations
|
|
export default resources;
|