1. Spanish translations for TecDoc catalog (translations.py) applied to catalog_service.py and dashboard server.py endpoints 2. Printable quotation HTML endpoint (/pos/api/quotations/<id>/pdf) with @media print CSS for clean browser-to-PDF output 3. Web Push notifications to owner/admin on sale cancellation, stock zero, and cash register differences > $500. Includes service worker, VAPID key management, and subscription endpoints. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
108 lines
3.8 KiB
Python
108 lines
3.8 KiB
Python
# /home/Autopartes/pos/services/translations.py
|
|
"""Spanish translations for TecDoc catalog part names and categories.
|
|
|
|
Uses a dictionary of common English→Spanish auto part translations.
|
|
Falls back to the original name if no match is found.
|
|
"""
|
|
|
|
PART_TRANSLATIONS = {
|
|
'Brake Pad Set': 'Juego de Balatas',
|
|
'Brake Disc': 'Disco de Freno',
|
|
'Shock Absorber': 'Amortiguador',
|
|
'Oil Filter': 'Filtro de Aceite',
|
|
'Air Filter': 'Filtro de Aire',
|
|
'Spark Plug': 'Bujía',
|
|
'Water Pump': 'Bomba de Agua',
|
|
'Alternator': 'Alternador',
|
|
'Starter Motor': 'Motor de Arranque',
|
|
'Radiator': 'Radiador',
|
|
'Thermostat': 'Termostato',
|
|
'Timing Belt': 'Banda de Distribución',
|
|
'V-Belt': 'Banda Serpentina',
|
|
'Serpentine Belt': 'Banda Serpentina',
|
|
'Clutch Kit': 'Kit de Embrague',
|
|
'Fuel Pump': 'Bomba de Gasolina',
|
|
'Fuel Filter': 'Filtro de Gasolina',
|
|
'Oxygen Sensor': 'Sensor de Oxígeno',
|
|
'Ignition Coil': 'Bobina de Encendido',
|
|
'Wheel Bearing': 'Balero de Rueda',
|
|
'Tie Rod End': 'Terminal de Dirección',
|
|
'Ball Joint': 'Rótula',
|
|
'CV Joint': 'Junta Homocinética',
|
|
'Wiper Blade': 'Pluma Limpiaparabrisas',
|
|
'Battery': 'Batería',
|
|
'Headlight': 'Faro Delantero',
|
|
'Tail Light': 'Calavera Trasera',
|
|
'Mirror': 'Espejo',
|
|
'Muffler': 'Mofle',
|
|
'Exhaust Pipe': 'Tubo de Escape',
|
|
'Catalytic Converter': 'Catalizador',
|
|
'Piston': 'Pistón',
|
|
'Gasket': 'Junta/Empaque',
|
|
'Valve': 'Válvula',
|
|
'Camshaft': 'Árbol de Levas',
|
|
'Crankshaft': 'Cigüeñal',
|
|
'Connecting Rod': 'Biela',
|
|
'Engine Mount': 'Soporte de Motor',
|
|
'Transmission Mount': 'Soporte de Transmisión',
|
|
'Control Arm': 'Brazo de Suspensión',
|
|
'Strut': 'Puntal',
|
|
'Spring': 'Resorte',
|
|
'Stabilizer Bar': 'Barra Estabilizadora',
|
|
'Brake Caliper': 'Caliper de Freno',
|
|
'Brake Drum': 'Tambor de Freno',
|
|
'Brake Hose': 'Manguera de Freno',
|
|
'Master Cylinder': 'Cilindro Maestro',
|
|
'Wheel Cylinder': 'Cilindro de Rueda',
|
|
'Power Steering Pump': 'Bomba de Dirección Hidráulica',
|
|
'Rack and Pinion': 'Cremallera de Dirección',
|
|
'A/C Compressor': 'Compresor de Aire Acondicionado',
|
|
'Condenser': 'Condensador',
|
|
'Evaporator': 'Evaporador',
|
|
'Heater Core': 'Radiador de Calefacción',
|
|
'Blower Motor': 'Motor de Ventilador',
|
|
'Tensioner': 'Tensor',
|
|
'Idler Pulley': 'Polea Loca',
|
|
'Flywheel': 'Volante de Motor',
|
|
'Injector': 'Inyector',
|
|
'Throttle Body': 'Cuerpo de Aceleración',
|
|
'Mass Air Flow Sensor': 'Sensor MAF',
|
|
'Coolant': 'Anticongelante',
|
|
'Brake Fluid': 'Líquido de Frenos',
|
|
'Transmission Fluid': 'Aceite de Transmisión',
|
|
'Engine Oil': 'Aceite de Motor',
|
|
# Categories
|
|
'Braking System': 'Sistema de Frenos',
|
|
'Engine': 'Motor',
|
|
'Suspension/Damping': 'Suspensión',
|
|
'Electrics': 'Eléctrico',
|
|
'Cooling System': 'Sistema de Enfriamiento',
|
|
'Exhaust System': 'Sistema de Escape',
|
|
'Fuel Mixture Formation': 'Sistema de Combustible',
|
|
'Steering': 'Dirección',
|
|
'Filters': 'Filtros',
|
|
'Belt Drive': 'Bandas y Poleas',
|
|
'Spark/Glow Ignition': 'Encendido',
|
|
'Heating/Ventilation': 'Calefacción/Ventilación',
|
|
'Maintenance Service Parts': 'Partes de Mantenimiento',
|
|
'Axle Drive': 'Transmisión/Ejes',
|
|
'Body': 'Carrocería',
|
|
'Axle Mounting/ Steering/ Wheels': 'Suspensión/Dirección/Ruedas',
|
|
}
|
|
|
|
|
|
def translate_part_name(name):
|
|
"""Translate a part name from English to Spanish. Uses partial matching."""
|
|
if not name:
|
|
return name
|
|
name_upper = name.upper()
|
|
for en, es in PART_TRANSLATIONS.items():
|
|
if en.upper() in name_upper:
|
|
return name.replace(en, es).replace(en.lower(), es.lower()).replace(en.upper(), es.upper())
|
|
return name
|
|
|
|
|
|
def translate_category(name):
|
|
"""Translate a category name."""
|
|
return PART_TRANSLATIONS.get(name, name)
|