/** * Node.js script to verify i18n translations for MyBookingsBook component * Run with: node test/i18n-verify.js */ import { readFileSync } from 'fs'; import { fileURLToPath } from 'url'; import { dirname, join } from 'path'; const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); const enPath = join(__dirname, '../src/i18n/locales/en.json'); const daPath = join(__dirname, '../src/i18n/locales/da.json'); const en = JSON.parse(readFileSync(enPath, 'utf-8')); const da = JSON.parse(readFileSync(daPath, 'utf-8')); const bookingKeys = [ 'guest_mode_warning', 'guest_mode_login_prompt', 'login', 'select_wash_hall', 'select_vehicle', 'is_this_your_vehicle', 'next_step_addons', 'product_selection_unavailable', 'login_for_products', 'interior_wash', 'exterior_wash', 'no_items_in_basket', 'total', 'required', 'expected_date_time', 'reference', 'po_number', 'note', 'customer_number', 'enter_customer_number', 'customer_not_found', 'pickup', 'incl_pickup', 'basket', 'step_x_of_y', 'select_a_wash_hall', 'enter_vehicle', 'select_products', 'select_date_time_customer', 'back', 'next', 'go_to_confirmation', 'missing_wash_hall', 'missing_customer_number', 'missing_valid_customer_number', 'missing_vehicle', 'missing_date', 'missing_products', 'error_copied', 'guest_info_html', 'confirm_booking' ]; const commonKeys = ['select', 'during_the_day', 'approx', 'thank_you', 'booking_created', 'unknown_error', 'error_creating_booking', 'try_again', 'copy_error', 'cancel', 'close', 'confirm']; let allPassed = true; console.log('=== i18n Translation Verification ===\n'); // Check EN booking keys const enBook = en.user_dashboard?.bookings?.book || {}; const enBookMissing = bookingKeys.filter(k => !enBook[k]); if (enBookMissing.length > 0) { console.log('❌ EN booking keys missing:', enBookMissing); allPassed = false; } else { console.log('✅ EN booking keys: All', bookingKeys.length, 'keys present'); } // Check DA booking keys const daBook = da.user_dashboard?.bookings?.book || {}; const daBookMissing = bookingKeys.filter(k => !daBook[k]); if (daBookMissing.length > 0) { console.log('❌ DA booking keys missing:', daBookMissing); allPassed = false; } else { console.log('✅ DA booking keys: All', bookingKeys.length, 'keys present'); } // Check EN common keys const enCommonMissing = commonKeys.filter(k => !en.common?.[k]); if (enCommonMissing.length > 0) { console.log('❌ EN common keys missing:', enCommonMissing); allPassed = false; } else { console.log('✅ EN common keys: All', commonKeys.length, 'keys present'); } // Check DA common keys const daCommonMissing = commonKeys.filter(k => !da.common?.[k]); if (daCommonMissing.length > 0) { console.log('❌ DA common keys missing:', daCommonMissing); allPassed = false; } else { console.log('✅ DA common keys: All', commonKeys.length, 'keys present'); } console.log('\n=== Result ==='); if (allPassed) { console.log('✅ All translation keys are properly defined!'); process.exit(0); } else { console.log('❌ Some translation keys are missing!'); process.exit(1); }