S SmartDocs
Série: ocpp python 309 linhas · Atualizado 2026-02-03

language_manager.py

ocpp/homework/ui_hori/language_manager.py

# -*- coding: utf-8 -*-
"""
Language Translation System for Charging Station UI
"""

class LanguageManager:
    def __init__(self):
        self.current_language = "English"
        self.translations = {
            "Traditional Chinese": {
                "welcome": "歡迎",
                "charging_station": "充電站",
                "start": "開始",
                "next": "下一步",
                "previous": "上一步",
                "exit": "退出",
                "retry": "重試",
                "ok": "確定",
                "stop": "停止",
                "continue": "繼續",
                "open_charging_cover": "打開充電蓋",
                "choose_charging_interface": "選擇與車輛相容的充電介面",
                "remove_charging_gun": "取下充電槍並插入車輛的充電介面",
                "choose_start_charging": "選擇一種方式開始充電",
                "use_app_scan_qr": "使用APP掃描QR碼",
                "place_rfid_card": "將RFID卡靠近充電樁的感應區域",
                "access_granted": "存取已授權",
                "card_id": "卡片ID:",
                "start_charging": "開始充電",
                "battery_charging": "電池充電中",
                "voltage": "電壓",
                "charging_time": "充電時間",
                "current": "電流",
                "co2_saved": "節省CO2",
                "power": "功率",
                "charging_cost": "充電費用",
                "billing_details": "帳單詳情",
                "charging_date_time": "充電日期/時間",
                "charging_power": "充電功率",
                "payment_method": "付款方式",
                "cost_calculation": "費用計算",
                "payment_information": "付款資訊",
                "remove_gun_return": "取下充電槍並歸還到充電站的指定位置",
                "confirm_port_cover": "確認車輛的充電口蓋已安全關閉",
                "ensure_no_items": "確保車輛和充電站周圍沒有遺留物品",
                "thank_you": "謝謝您",
                "timestamp": "時間戳記",
                "welcome_to_system": "歡迎使用系統"
            },
            "Simplified Chinese": {
                "welcome": "欢迎",
                "charging_station": "充电站",
                "start": "开始",
                "next": "下一步",
                "previous": "上一步",
                "exit": "退出",
                "retry": "重试",
                "ok": "确定",
                "stop": "停止",
                "continue": "继续",
                "open_charging_cover": "打开充电盖",
                "choose_charging_interface": "选择与车辆兼容的充电接口",
                "remove_charging_gun": "取下充电枪并插入车辆的充电接口",
                "choose_start_charging": "选择一种方式开始充电",
                "use_app_scan_qr": "使用APP扫描QR码",
                "place_rfid_card": "将RFID卡靠近充电桩的感应区域",
                "access_granted": "访问已授权",
                "card_id": "卡片ID:",
                "start_charging": "开始充电",
                "battery_charging": "电池充电中",
                "voltage": "电压",
                "charging_time": "充电时间",
                "current": "电流",
                "co2_saved": "节省CO2",
                "power": "功率",
                "charging_cost": "充电费用",
                "billing_details": "账单详情",
                "charging_date_time": "充电日期/时间",
                "charging_power": "充电功率",
                "payment_method": "付款方式",
                "cost_calculation": "费用计算",
                "payment_information": "付款信息",
                "remove_gun_return": "取下充电枪并归还到充电站的指定位置",
                "confirm_port_cover": "确认车辆的充电口盖已安全关闭",
                "ensure_no_items": "确保车辆和充电站周围没有遗留物品",
                "thank_you": "谢谢您",
                "timestamp": "时间戳",
                "welcome_to_system": "欢迎使用系统"
            },
            "English": {
                "welcome": "Welcome",
                "charging_station": "Charging Station",
                "start": "Start",
                "next": "Next",
                "previous": "Previous",
                "exit": "Exit",
                "retry": "Retry",
                "ok": "OK",
                "stop": "Stop",
                "continue": "Continue",
                "open_charging_cover": "Open the charging cover",
                "choose_charging_interface": "Choose the charging interface is compatible with the vehicle",
                "remove_charging_gun": "Remove the charging gun and insert it into the vehicle's charging interface",
                "choose_start_charging": "Choose one to start charging",
                "use_app_scan_qr": "Use APP to Scan the QR code",
                "place_rfid_card": "Place the RFID card close to the card sensing zone on the pile",
                "access_granted": "Access granted",
                "card_id": "Card ID:",
                "start_charging": "Start Charging",
                "battery_charging": "Battery Charging",
                "voltage": "Voltage",
                "charging_time": "Charging Time",
                "current": "Current",
                "co2_saved": "CO2 Saved",
                "power": "Power",
                "charging_cost": "Charging Cost",
                "billing_details": "Billing Details",
                "charging_date_time": "Charging Date / Time",
                "charging_power": "Charging power",
                "payment_method": "Payment Method",
                "cost_calculation": "Cost Calculation",
                "payment_information": "Payment Information",
                "remove_gun_return": "Remove the charging gun and return it to the designated position on the charging station",
                "confirm_port_cover": "Confirm that the charging port cover on the vehicle is securely closed",
                "ensure_no_items": "Ensure that there are no items left around the vehicle and charging station",
                "thank_you": "Thank You",
                "timestamp": "Timestamp",
                "welcome_to_system": "Welcome to the system"
            },
            "Japanese": {
                "welcome": "ようこそ",
                "charging_station": "充電ステーション",
                "start": "開始",
                "next": "次へ",
                "previous": "前へ",
                "exit": "終了",
                "retry": "再試行",
                "ok": "OK",
                "stop": "停止",
                "continue": "続行",
                "open_charging_cover": "充電カバーを開く",
                "choose_charging_interface": "車両と互換性のある充電インターフェースを選択",
                "remove_charging_gun": "充電ガンを取り外し、車両の充電インターフェースに挿入",
                "choose_start_charging": "充電を開始する方法を選択",
                "use_app_scan_qr": "アプリでQRコードをスキャン",
                "place_rfid_card": "RFIDカードを充電スタンドのセンサーゾーンに近づける",
                "access_granted": "アクセス許可済み",
                "card_id": "カードID:",
                "start_charging": "充電開始",
                "battery_charging": "バッテリー充電中",
                "voltage": "電圧",
                "charging_time": "充電時間",
                "current": "電流",
                "co2_saved": "CO2削減",
                "power": "電力",
                "charging_cost": "充電料金",
                "billing_details": "請求詳細",
                "charging_date_time": "充電日時",
                "charging_power": "充電電力",
                "payment_method": "支払い方法",
                "cost_calculation": "料金計算",
                "payment_information": "支払い情報",
                "remove_gun_return": "充電ガンを取り外し、充電ステーションの指定位置に戻す",
                "confirm_port_cover": "車両の充電ポートカバーが安全に閉じられていることを確認",
                "ensure_no_items": "車両と充電ステーション周辺に物が残っていないことを確認",
                "thank_you": "ありがとうございました",
                "timestamp": "タイムスタンプ",
                "welcome_to_system": "システムへようこそ"
            },
            "Thai": {
                "welcome": "ยินดีต้อนรับ",
                "charging_station": "สถานีชาร์จ",
                "start": "เริ่มต้น",
                "next": "ถัดไป",
                "previous": "ก่อนหน้า",
                "exit": "ออก",
                "retry": "ลองใหม่",
                "ok": "ตกลง",
                "stop": "หยุด",
                "continue": "ดำเนินการต่อ",
                "open_charging_cover": "เปิดฝาครอบการชาร์จ",
                "choose_charging_interface": "เลือกอินเทอร์เฟซการชาร์จที่เข้ากันได้กับรถยนต์",
                "remove_charging_gun": "ถอดปืนชาร์จและใส่เข้าไปในอินเทอร์เฟซการชาร์จของรถยนต์",
                "choose_start_charging": "เลือกวิธีหนึ่งเพื่อเริ่มการชาร์จ",
                "use_app_scan_qr": "ใช้แอปสแกนQR Code",
                "place_rfid_card": "วางบัตรRFIDใกล้กับโซนเซ็นเซอร์บนเสาชาร์จ",
                "access_granted": "ได้รับอนุญาตแล้ว",
                "card_id": "รหัสบัตร:",
                "start_charging": "เริ่มการชาร์จ",
                "battery_charging": "กำลังชาร์จแบตเตอรี่",
                "voltage": "แรงดันไฟฟ้า",
                "charging_time": "เวลาการชาร์จ",
                "current": "กระแสไฟฟ้า",
                "co2_saved": "ประหยัดCO2",
                "power": "กำลังไฟฟ้า",
                "charging_cost": "ค่าใช้จ่ายการชาร์จ",
                "billing_details": "รายละเอียดการเรียกเก็บเงิน",
                "charging_date_time": "วันที่/เวลาการชาร์จ",
                "charging_power": "กำลังการชาร์จ",
                "payment_method": "วิธีการชำระเงิน",
                "cost_calculation": "การคำนวณต้นทุน",
                "payment_information": "ข้อมูลการชำระเงิน",
                "remove_gun_return": "ถอดปืนชาร์จและคืนไปยังตำแหน่งที่กำหนดบนสถานีชาร์จ",
                "confirm_port_cover": "ยืนยันว่าฝาครอบพอร์ตชาร์จบนรถยนต์ปิดอย่างปลอดภัย",
                "ensure_no_items": "ตรวจสอบให้แน่ใจว่าไม่มีสิ่งของเหลืออยู่รอบๆ รถยนต์และสถานีชาร์จ",
                "thank_you": "ขอบคุณ",
                "timestamp": "เวลาประทับ",
                "welcome_to_system": "ยินดีต้อนรับสู่ระบบ"
            },
            "Vietnamese": {
                "welcome": "Chào mừng",
                "charging_station": "Trạm sạc",
                "start": "Bắt đầu",
                "next": "Tiếp theo",
                "previous": "Trước đó",
                "exit": "Thoát",
                "retry": "Thử lại",
                "ok": "OK",
                "stop": "Dừng",
                "continue": "Tiếp tục",
                "open_charging_cover": "Mở nắp sạc",
                "choose_charging_interface": "Chọn giao diện sạc tương thích với xe",
                "remove_charging_gun": "Tháo súng sạc và cắm vào giao diện sạc của xe",
                "choose_start_charging": "Chọn một cách để bắt đầu sạc",
                "use_app_scan_qr": "Sử dụng APP để quét mã QR",
                "place_rfid_card": "Đặt thẻ RFID gần vùng cảm biến trên cột sạc",
                "access_granted": "Đã được cấp quyền truy cập",
                "card_id": "ID thẻ:",
                "start_charging": "Bắt đầu sạc",
                "battery_charging": "Đang sạc pin",
                "voltage": "Điện áp",
                "charging_time": "Thời gian sạc",
                "current": "Dòng điện",
                "co2_saved": "Tiết kiệm CO2",
                "power": "Công suất",
                "charging_cost": "Chi phí sạc",
                "billing_details": "Chi tiết hóa đơn",
                "charging_date_time": "Ngày/giờ sạc",
                "charging_power": "Công suất sạc",
                "payment_method": "Phương thức thanh toán",
                "cost_calculation": "Tính toán chi phí",
                "payment_information": "Thông tin thanh toán",
                "remove_gun_return": "Tháo súng sạc và trả về vị trí được chỉ định trên trạm sạc",
                "confirm_port_cover": "Xác nhận nắp cổng sạc trên xe đã được đóng an toàn",
                "ensure_no_items": "Đảm bảo không có vật dụng nào còn lại xung quanh xe và trạm sạc",
                "thank_you": "Cảm ơn bạn",
                "timestamp": "Dấu thời gian",
                "welcome_to_system": "Chào mừng đến với hệ thống"
            },
            "Spanish": {
                "welcome": "Bienvenido",
                "charging_station": "Estación de Carga",
                "start": "Iniciar",
                "next": "Siguiente",
                "previous": "Anterior",
                "exit": "Salir",
                "retry": "Reintentar",
                "ok": "OK",
                "stop": "Detener",
                "continue": "Continuar",
                "open_charging_cover": "Abrir la tapa de carga",
                "choose_charging_interface": "Elegir la interfaz de carga compatible con el vehículo",
                "remove_charging_gun": "Retirar la pistola de carga e insertarla en la interfaz de carga del vehículo",
                "choose_start_charging": "Elegir una opción para comenzar la carga",
                "use_app_scan_qr": "Usar APP para escanear el código QR",
                "place_rfid_card": "Colocar la tarjeta RFID cerca de la zona de detección en el poste",
                "access_granted": "Acceso autorizado",
                "card_id": "ID de tarjeta:",
                "start_charging": "Iniciar Carga",
                "battery_charging": "Cargando Batería",
                "voltage": "Voltaje",
                "charging_time": "Tiempo de Carga",
                "current": "Corriente",
                "co2_saved": "CO2 Ahorrado",
                "power": "Potencia",
                "charging_cost": "Costo de Carga",
                "billing_details": "Detalles de Facturación",
                "charging_date_time": "Fecha/Hora de Carga",
                "charging_power": "Potencia de carga",
                "payment_method": "Método de Pago",
                "cost_calculation": "Cálculo de Costos",
                "payment_information": "Información de Pago",
                "remove_gun_return": "Retirar la pistola de carga y devolverla a la posición designada en la estación de carga",
                "confirm_port_cover": "Confirmar que la tapa del puerto de carga del vehículo está cerrada de forma segura",
                "ensure_no_items": "Asegurar que no hay objetos dejados alrededor del vehículo y la estación de carga",
                "thank_you": "Gracias",
                "timestamp": "Marca de tiempo",
                "welcome_to_system": "Bienvenido al sistema"
            }
        }
    
    def get_text(self, key):
        """Get translated text for current language"""
        if self.current_language in self.translations and key in self.translations[self.current_language]:
            return self.translations[self.current_language][key]
        # Fallback to English if translation not found
        return self.translations["English"].get(key, key)
    
    def set_language(self, language):
        """Set current language"""
        if language in self.translations:
            self.current_language = language
    
    def get_available_languages(self):
        """Get list of available languages"""
        return list(self.translations.keys())

# Global language manager instance
language_manager = LanguageManager()

Artigos relacionados