#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import locale

"""
Internationalization module for FUSS Reader.
Provides a translation dictionary for the supported languages (IT, DE, EN, ES, FR).
"""

# Translation dictionary for FUSS Reader
TRANSLATIONS = {
    "it": {
        "title": "FUSS READER - LETTORE VOCALE",
        "voice_select": " SELEZIONE VOCE ",
        "speed": " VELOCIT\u00C0 ",
        "btn_open": "📂 APRI",
        "btn_paste": "📋 INCOLLA",
        "btn_play": "▶ PLAY",
        "btn_pause": "⏸ PAUSA",
        "btn_resume": "▶ RIPRENDI",
        "btn_stop": "■ STOP",
        "btn_clear": "👤 SVUOTA",
        "btn_exit": "ESCI",
        "msg_welcome": "Benvenuto. Clicca su APRI per caricare un file o incolla qui il testo.",
        "msg_empty": "Posiziona il cursore dove vuoi iniziare a leggere.",
        "msg_error": "Errore durante la lettura del file: ",
        "fem": "Femminile",
        "mas": "Maschile",
        "menu_cut": "Taglia",
        "menu_copy": "Copia",
        "menu_paste": "Incolla",
        "menu_select_all": "Seleziona tutto",
        "confirm_clear_title": "Svuota",
        "confirm_clear_msg": "Vuoi cancellare tutto il testo?"
    },
    "de": {
        "title": "FUSS READER - VORLESESYSTEM",
        "voice_select": " SPRACHAUSWAHL ",
        "speed": " GESCHWINDIGKEIT ",
        "btn_open": "📂 ÖFFNEN",
        "btn_paste": "📋 EINFÜGEN",
        "btn_play": "▶ PLAY",
        "btn_pause": "⏸ PAUSE",
        "btn_resume": "▶ WEITER",
        "btn_stop": "■ STOP",
        "btn_clear": "👤 LEEREN",
        "btn_exit": "BEENDEN",
        "msg_welcome": "Willkommen. Klicken Sie auf ÖFFNEN oder fügen Sie Text hier ein.",
        "msg_empty": "Cursor an den Anfang des zu lesenden Textes setzen.",
        "msg_error": "Fehler beim Lesen der Datei: ",
        "fem": "Weiblich",
        "mas": "Männlich",
        "menu_cut": "Ausschneiden",
        "menu_copy": "Kopieren",
        "menu_paste": "Einfügen",
        "menu_select_all": "Alles auswählen",
        "confirm_clear_title": "Leeren",
        "confirm_clear_msg": "Möchten Sie den gesamten Text löschen?"
    },
    "en": {
        "title": "FUSS READER - SPEECH READER",
        "voice_select": " VOICE SELECTION ",
        "speed": " SPEED ",
        "btn_open": "📂 OPEN",
        "btn_paste": "📋 PASTE",
        "btn_play": "▶ PLAY",
        "btn_pause": "⏸ PAUSE",
        "btn_resume": "▶ RESUME",
        "btn_stop": "■ STOP",
        "btn_clear": "👤 CLEAR",
        "btn_exit": "EXIT",
        "msg_welcome": "Welcome. Click OPEN to load a file or paste text here.",
        "msg_empty": "Place the cursor where you want to start reading.",
        "msg_error": "Error reading file: ",
        "fem": "Female",
        "mas": "Male",
        "menu_cut": "Cut",
        "menu_copy": "Copy",
        "menu_paste": "Paste",
        "menu_select_all": "Select all",
        "confirm_clear_title": "Clear",
        "confirm_clear_msg": "Do you want to clear all text?"
    },
    "es": {
        "title": "FUSS READER - LECTOR DE VOZ",
        "voice_select": " SELECCIÓN DE VOZ ",
        "speed": " VELOCIDAD ",
        "btn_open": "📂 ABRIR",
        "btn_paste": "📋 PEGAR",
        "btn_play": "▶ PLAY",
        "btn_pause": "⏸ PAUSA",
        "btn_resume": "▶ REANUDAR",
        "btn_stop": "■ STOP",
        "btn_clear": "👤 LIMPIAR",
        "btn_exit": "SALIR",
        "msg_welcome": "Bienvenido. Haga clic en ABRIR o pegue texto aquí.",
        "msg_empty": "Coloque el cursor donde quiera empezar a leer.",
        "msg_error": "Error al leer el archivo: ",
        "fem": "Femenino",
        "mas": "Masculino",
        "menu_cut": "Cortar",
        "menu_copy": "Copiar",
        "menu_paste": "Pegar",
        "menu_select_all": "Seleccionar todo",
        "confirm_clear_title": "Limpiar",
        "confirm_clear_msg": "¿Quieres borrar todo el texto?"
    },
    "fr": {
        "title": "FUSS READER - LECTEUR VOCAL",
        "voice_select": " SÉLECTION DE LA VOIX ",
        "speed": " VITESSE ",
        "btn_open": "📂 OUVRIR",
        "btn_paste": "📋 COLLER",
        "btn_play": "▶ PLAY",
        "btn_pause": "⏸ PAUSE",
        "btn_resume": "▶ REPRENDRE",
        "btn_stop": "■ STOP",
        "btn_clear": "👤 EFFACER",
        "btn_exit": "QUITTER",
        "msg_welcome": "Bienvenue. Cliquez sur OUVRIR ou collez du texte ici.",
        "msg_empty": "Placez le curseur là où vous souhaitez commencer la lecture.",
        "msg_error": "Erreur lors de la lecture du fichier : ",
        "fem": "Féminin",
        "mas": "Masculin",
        "menu_cut": "Couper",
        "menu_copy": "Copier",
        "menu_paste": "Coller",
        "menu_select_all": "Tout sélectionner",
        "confirm_clear_title": "Effacer",
        "confirm_clear_msg": "Voulez-vous effacer tout le texte ?"
    }
}

def get_strings():
    """
    Detects the system language and returns the corresponding string dictionary.
    """
    try:
        # Get the system language (e.g. 'it_IT', 'de_DE', etc.)
        lang_code = locale.getdefaultlocale()[0]
        if lang_code:
            # Get only the first two letters ('it', 'de')
            lang = lang_code[:2].lower()
        else:
            lang = "it"
    except:
        lang = "it"
    
    # Return the language dictionary or Italian as a fallback
    return TRANSLATIONS.get(lang, TRANSLATIONS["it"])
