/*
[SCE CONFIDENTIAL]
$PSDocId$
                  Copyright (C) 2002-4 Sony Computer Entertainment America
                                                     All Rights Reserved
//  ------------------------------------------------------------------------

File: i18n_eu.c

- Broadband message tables (Ethernet and PPPoE) localized for SCEE titles.
  DO NOT use these tables below for SCEA titles, since they do not include
  modem-related messages.

- also contains sample ezNetCtlSetLanguage() and ezNetCtlSetScfLanguage()
  routines, located after message table definitions.

- see lib-src/i18n.c for implementation notes and default English messages.

//  ------------------------------------------------------------------------
*/

#include <eekernel.h>
#include <libscf.h>

// (MH - 18.03.2005) added
#include <stddef.h>

#include "../include/eznetcnf.h"
#include "../include/eznetctl_i18n.h"


/*  --------------------------------------------------------
 *  French
 *  --------------------------------------------------------
 */

static
ezMsgFormat_t m_errorMsgs_fr[] = {
    //  DHCP errors
    //  libeenet only
    {   sceEENETCTL_E_DhcpMalformedPkt,
        sceEENETCTL_E_DhcpNoServer,
        "Erreur de configuration du DHCP",
        NULL
    },

    //  PPP/PPPoE errors (cascaded)
    //  libeenet and Inet
    {   sceEENETCTL_E_PppAuth,
        sceEENETCTL_E_PppAuth,
        "Erreur d'authentification de l'utilisateur avec le FAI\n%s",
        cbFormatAuthMessage
    },
    {   sceEENETCTL_E_PppTerminate,
        sceEENETCTL_E_PppLinkEstab,
        "Erreur de connexion avec le FAI",
        NULL
    },

    //  PPPoE errors (cascaded)
    //  libeenet only
    {   sceEENETCTL_EE_PppoeGetPADT,
        sceEENETCTL_EE_PppoeGetPADT,
        "Session PPPoE interrompue par le FAI",
        NULL
    },
    {   sceEENETCTL_EE_PppoeUnknown,
        sceEENETCTL_EE_PppoeServiceName,
        "Erreur de session PPPoE avec le FAI",
        NULL
    },

    //  terminator
    {   0, 0, NULL, NULL }
};

static
ezMsgFormat_t m_phaseMsgs_fr[] = {
    //  DHCP phases (cascaded)
    //  libeenet only
    {   sceEENETCTL_P_DhcpBound,
        sceEENETCTL_P_DhcpBound,
        "Configuration du DHCP réussie",
        NULL
    },
    {   sceEENETCTL_P_DhcpInit,
        sceEENETCTL_P_DhcpRebinding,
        "Demande de configuration du DHCP",
        NULL
    },
    
    //  PPP/PPPoE phases (cascaded)
    //  libeenet and Inet
    {   sceEENETCTL_P_PppDead,
        sceEENETCTL_P_PppDead,
        "Pas de connexion",
        NULL
    },
    {   sceEENETCTL_P_PppNetwork,
        sceEENETCTL_P_PppNetwork,
        "Connexion établie avec le FAI",
        NULL
    },
    {   sceEENETCTL_P_PppEstablish,
        sceEENETCTL_P_PppAuth,
        "Établissement de la connexion avec le FAI",
        NULL
    },

    //  PPPoE phases (cascaded)
    //  libeenet only
    {   sceEENETCTL_PP_PppoeSession,
        sceEENETCTL_PP_PppoeSession,
        "Session PPPoE établie",
        NULL
    },
    {   sceEENETCTL_PP_PppoeInit,
        sceEENETCTL_PP_PppoeClosing,
        "Établissement de la session PPPoE",
        NULL
    },

    //  terminator
    {   0, 0, NULL, NULL }
};

static
ezMsgFormat_t m_stateMsgs_fr[] = {
    //  generic network states (complete)
    //  libeenet and Inet
    {   sceEENETCTL_S_DETACHED,
        sceEENETCTL_S_DETACHED,
        "Le matériel réseau est débranché",
        NULL
    },
    {   sceEENETCTL_S_STARTING,
        sceEENETCTL_S_STARTING,
        "Connexion au réseau",
        NULL
    },
    {   sceEENETCTL_S_RETRYING,
        sceEENETCTL_S_RETRYING,
        "Nouvelle tentative en attente",
        NULL
    },
    {   sceEENETCTL_S_STARTED,
        sceEENETCTL_S_STARTED,
        "Connecté au réseau",
        NULL
    },
    {   sceEENETCTL_S_STOPPING,
        sceEENETCTL_S_STOPPING,
        "Déconnexion du réseau",
        NULL
    },
    {   sceEENETCTL_S_STOPPED,
        sceEENETCTL_S_STOPPED,
        "Déconnecté du réseau",
        NULL
    },
    {   sceEENETCTL_S_DETACHING,
        sceEENETCTL_S_DETACHING,
        "Débranchement du matériel réseau",
        NULL
    },

    //  terminator
    {   0, 0, NULL, NULL }
};


/*  --------------------------------------------------------
 *  Spanish
 *  --------------------------------------------------------
 */

static
ezMsgFormat_t m_errorMsgs_es[] = {
    //  DHCP errors
    //  libeenet only
    {   sceEENETCTL_E_DhcpMalformedPkt,
        sceEENETCTL_E_DhcpNoServer,
        "Error de configuración de DHCP",
        NULL
    },

    //  PPP/PPPoE errors (cascaded)
    //  libeenet and Inet
    {   sceEENETCTL_E_PppAuth,
        sceEENETCTL_E_PppAuth,
        "Error de autenticación de usuario con ISP\n%s",
        cbFormatAuthMessage
    },
    {   sceEENETCTL_E_PppTerminate,
        sceEENETCTL_E_PppLinkEstab,
        "Error de conexión con ISP",
        NULL
    },

    //  PPPoE errors (cascaded)
    //  libeenet only
    {   sceEENETCTL_EE_PppoeGetPADT,
        sceEENETCTL_EE_PppoeGetPADT,
        "Sesión PPPoE finalizada por el ISP",
        NULL
    },
    {   sceEENETCTL_EE_PppoeUnknown,
        sceEENETCTL_EE_PppoeServiceName,
        "Error de sesión PPPoE con ISP",
        NULL
    },

    //  terminator
    {   0, 0, NULL, NULL }
};

static
ezMsgFormat_t m_phaseMsgs_es[] = {
    //  DHCP phases (cascaded)
    //  libeenet only
    {   sceEENETCTL_P_DhcpBound,
        sceEENETCTL_P_DhcpBound,
        "Configuración de DHCP con éxito",
        NULL
    },
    {   sceEENETCTL_P_DhcpInit,
        sceEENETCTL_P_DhcpRebinding,
        "Solicitando configuración de DHCP",
        NULL
    },
    
    //  PPP/PPPoE phases (cascaded)
    //  libeenet and Inet
    {   sceEENETCTL_P_PppDead,
        sceEENETCTL_P_PppDead,
        "Conexión finalizada",
        NULL
    },
    {   sceEENETCTL_P_PppNetwork,
        sceEENETCTL_P_PppNetwork,
        "Conexión establecida con ISP",
        NULL
    },
    {   sceEENETCTL_P_PppEstablish,
        sceEENETCTL_P_PppAuth,
        "Estableciendo conexión con ISP",
        NULL
    },

    //  PPPoE phases (cascaded)
    //  libeenet only
    {   sceEENETCTL_PP_PppoeSession,
        sceEENETCTL_PP_PppoeSession,
        "Sesión PPPoE establecida",
        NULL
    },
    {   sceEENETCTL_PP_PppoeInit,
        sceEENETCTL_PP_PppoeClosing,
        "Estableciendo sesión PPPoE",
        NULL
    },

    //  terminator
    {   0, 0, NULL, NULL }
};

static
ezMsgFormat_t m_stateMsgs_es[] = {
    //  generic network states (complete)
    //  libeenet and Inet
    {   sceEENETCTL_S_DETACHED,
        sceEENETCTL_S_DETACHED,
        "Se ha desconectado el hardware de red",
        NULL
    },
    {   sceEENETCTL_S_STARTING,
        sceEENETCTL_S_STARTING,
        "Conectando a la red",
        NULL
    },
    {   sceEENETCTL_S_RETRYING,
        sceEENETCTL_S_RETRYING,
        "Esperando a reintentar",
        NULL
    },
    {   sceEENETCTL_S_STARTED,
        sceEENETCTL_S_STARTED,
        "Conectado a la red",
        NULL
    },
    {   sceEENETCTL_S_STOPPING,
        sceEENETCTL_S_STOPPING,
        "Desconectando de la red",
        NULL
    },
    {   sceEENETCTL_S_STOPPED,
        sceEENETCTL_S_STOPPED,
        "Desconectado de la red",
        NULL
    },
    {   sceEENETCTL_S_DETACHING,
        sceEENETCTL_S_DETACHING,
        "Se está desconectando el hardware de red",
        NULL
    },

    //  terminator
    {   0, 0, NULL, NULL }
};


/*  --------------------------------------------------------
 *  German
 *  --------------------------------------------------------
 */

static
ezMsgFormat_t m_errorMsgs_de[] = {
    //  DHCP errors
    //  libeenet only
    {   sceEENETCTL_E_DhcpMalformedPkt,
        sceEENETCTL_E_DhcpNoServer,
        "DHCP-Konfigurations-Fehler",
        NULL
    },

    //  PPP/PPPoE errors (cascaded)
    //  libeenet and Inet
    {   sceEENETCTL_E_PppAuth,
        sceEENETCTL_E_PppAuth,
        "ISP-Benutzer-Authentifizierungs-Fehler\n%s",
        cbFormatAuthMessage
    },
    {   sceEENETCTL_E_PppTerminate,
        sceEENETCTL_E_PppLinkEstab,
        "ISP-Verbindungs-Fehler",
        NULL
    },

    //  PPPoE errors (cascaded)
    //  libeenet only
    {   sceEENETCTL_EE_PppoeGetPADT,
        sceEENETCTL_EE_PppoeGetPADT,
        "PPPoE-Session durch ISP beendet",
        NULL
    },
    {   sceEENETCTL_EE_PppoeUnknown,
        sceEENETCTL_EE_PppoeServiceName,
        "ISP-PPPoE-Session-Fehler",
        NULL
    },

    //  terminator
    {   0, 0, NULL, NULL }
};

static
ezMsgFormat_t m_phaseMsgs_de[] = {
    //  DHCP phases (cascaded)
    //  libeenet only
    {   sceEENETCTL_P_DhcpBound,
        sceEENETCTL_P_DhcpBound,
        "DHCP-Konfiguration erfolgreich",
        NULL
    },
    {   sceEENETCTL_P_DhcpInit,
        sceEENETCTL_P_DhcpRebinding,
        "Fordert DHCP-Konfiguration an",
        NULL
    },
    
    //  PPP/PPPoE phases (cascaded)
    //  libeenet and Inet
    {   sceEENETCTL_P_PppDead,
        sceEENETCTL_P_PppDead,
        "Verbindung tot",
        NULL
    },
    {   sceEENETCTL_P_PppNetwork,
        sceEENETCTL_P_PppNetwork,
        "Verbindung mit ISP hergestellt",
        NULL
    },
    {   sceEENETCTL_P_PppEstablish,
        sceEENETCTL_P_PppAuth,
        "Stellt Verbindung mit ISP her",
        NULL
    },

    //  PPPoE phases (cascaded)
    //  libeenet only
    {   sceEENETCTL_PP_PppoeSession,
        sceEENETCTL_PP_PppoeSession,
        "PPPoE-Session hergestellt",
        NULL
    },
    {   sceEENETCTL_PP_PppoeInit,
        sceEENETCTL_PP_PppoeClosing,
        "Stellt PPPoE-Session her",
        NULL
    },

    //  terminator
    {   0, 0, NULL, NULL }
};

static
ezMsgFormat_t m_stateMsgs_de[] = {
    //  generic network states (complete)
    //  libeenet and Inet
    {   sceEENETCTL_S_DETACHED,
        sceEENETCTL_S_DETACHED,
        "Netzwerk-Hardware ist getrennt",
        NULL
    },
    {   sceEENETCTL_S_STARTING,
        sceEENETCTL_S_STARTING,
        "Verbindet mit Netzwerk",
        NULL
    },
    {   sceEENETCTL_S_RETRYING,
        sceEENETCTL_S_RETRYING,
        "Wartet auf Wiederholungsversuch",
        NULL
    },
    {   sceEENETCTL_S_STARTED,
        sceEENETCTL_S_STARTED,
        "Mit Netzwerk verbunden",
        NULL
    },
    {   sceEENETCTL_S_STOPPING,
        sceEENETCTL_S_STOPPING,
        "Trennt Verbindung mit Netzwerk",
        NULL
    },
    {   sceEENETCTL_S_STOPPED,
        sceEENETCTL_S_STOPPED,
        "Netzwerkverbindung getrennt",
        NULL
    },
    {   sceEENETCTL_S_DETACHING,
        sceEENETCTL_S_DETACHING,
        "Netzwerk-Hardware wird getrennt",
        NULL
    },

    //  terminator
    {   0, 0, NULL, NULL }
};


/*  --------------------------------------------------------
 *  Italian
 *  --------------------------------------------------------
 */

static
ezMsgFormat_t m_errorMsgs_it[] = {
    //  DHCP errors
    //  libeenet only
    {   sceEENETCTL_E_DhcpMalformedPkt,
        sceEENETCTL_E_DhcpNoServer,
        "Errore di configurazione DHCP",
        NULL
    },

    //  PPP/PPPoE errors (cascaded)
    //  libeenet and Inet
    {   sceEENETCTL_E_PppAuth,
        sceEENETCTL_E_PppAuth,
        "Errore di autenticazione dell'utente con l'ISP\n%s",
        cbFormatAuthMessage
    },
    {   sceEENETCTL_E_PppTerminate,
        sceEENETCTL_E_PppLinkEstab,
        "Errore di connessione con l'ISP",
        NULL
    },

    //  PPPoE errors (cascaded)
    //  libeenet only
    {   sceEENETCTL_EE_PppoeGetPADT,
        sceEENETCTL_EE_PppoeGetPADT,
        "Sessione PPPoE terminata dall'ISP",
        NULL
    },
    {   sceEENETCTL_EE_PppoeUnknown,
        sceEENETCTL_EE_PppoeServiceName,
        "Errore nella sessione PPPoE con l'ISP",
        NULL
    },

    //  terminator
    {   0, 0, NULL, NULL }
};

static
ezMsgFormat_t m_phaseMsgs_it[] = {
    //  DHCP phases (cascaded)
    //  libeenet only
    {   sceEENETCTL_P_DhcpBound,
        sceEENETCTL_P_DhcpBound,
        "Configurazione DHCP riuscita",
        NULL
    },
    {   sceEENETCTL_P_DhcpInit,
        sceEENETCTL_P_DhcpRebinding,
        "Richiesta configurazione DHCP...",
        NULL
    },
    
    //  PPP/PPPoE phases (cascaded)
    //  libeenet and Inet
    {   sceEENETCTL_P_PppDead,
        sceEENETCTL_P_PppDead,
        "Connessione interrotta",
        NULL
    },
    {   sceEENETCTL_P_PppNetwork,
        sceEENETCTL_P_PppNetwork,
        "Stabilita connessione con l'ISP",
        NULL
    },
    {   sceEENETCTL_P_PppEstablish,
        sceEENETCTL_P_PppAuth,
        "Connessione con l'ISP in corso...",
        NULL
    },

    //  PPPoE phases (cascaded)
    //  libeenet only
    {   sceEENETCTL_PP_PppoeSession,
        sceEENETCTL_PP_PppoeSession,
        "Avviata sessione PPPoE",
        NULL
    },
    {   sceEENETCTL_PP_PppoeInit,
        sceEENETCTL_PP_PppoeClosing,
        "Avvio sessione PPPoE in corso...",
        NULL
    },

    //  terminator
    {   0, 0, NULL, NULL }
};

static
ezMsgFormat_t m_stateMsgs_it[] = {
    //  generic network states (complete)
    //  libeenet and Inet
    {   sceEENETCTL_S_DETACHED,
        sceEENETCTL_S_DETACHED,
        "L'hardware di rete è scollegato",
        NULL
    },
    {   sceEENETCTL_S_STARTING,
        sceEENETCTL_S_STARTING,
        "Connessione alla rete in corso...",
        NULL
    },
    {   sceEENETCTL_S_RETRYING,
        sceEENETCTL_S_RETRYING,
        "In attesa di riprovare",
        NULL
    },
    {   sceEENETCTL_S_STARTED,
        sceEENETCTL_S_STARTED,
        "Connesso alla rete",
        NULL
    },
    {   sceEENETCTL_S_STOPPING,
        sceEENETCTL_S_STOPPING,
        "Sconnessione dalla rete in corso...",
        NULL
    },
    {   sceEENETCTL_S_STOPPED,
        sceEENETCTL_S_STOPPED,
        "Sconnesso dalla rete",
        NULL
    },
    {   sceEENETCTL_S_DETACHING,
        sceEENETCTL_S_DETACHING,
        "L'hardware di rete si sta scollegando",
        NULL
    },

    //  terminator
    {   0, 0, NULL, NULL }
};


/*  --------------------------------------------------------
 *  setup ezNetCtl to use the OSD Browser's language setting
 *
 *  important regional caveats --
 *  SCEE: unsupported languages setting => English messages
 *
 *  SCEJ: no Japanese localization yet  => English messages
 *
 *  SCEK: no Korean localization yet.
 *        also, libscf does not support SCE_LANGUAGE_KOREAN.
 *  --------------------------------------------------------
 */

static
ezMsgFormat_t *m_metaTable[][3] = {
    // SCE_JAPANESE_LANGUAGE
    { NULL, NULL, NULL },
    // SCE_ENGLISH_LANGUAGE
    { NULL, NULL, NULL },
    // SCE_FRENCH_LANGUAGE
    { m_errorMsgs_fr, m_phaseMsgs_fr, m_stateMsgs_fr },
    // SCE_SPANISH_LANGUAGE
    { m_errorMsgs_es, m_phaseMsgs_es, m_stateMsgs_es },
    // SCE_GERMAN_LANGUAGE
    { m_errorMsgs_de, m_phaseMsgs_de, m_stateMsgs_de },
    // SCE_ITALIAN_LANGUAGE
    { m_errorMsgs_it, m_phaseMsgs_it, m_stateMsgs_it },
};

void
ezNetCtlSetLanguage(unsigned int lang)
{
    // LHS variable is an -index-, RHS computes -count- of metaTable rows
    if (lang < (sizeof(m_metaTable) / sizeof(ezMsgFormat_t *) / 3)) {
        ezNetCtlSwapMessageTables(m_metaTable[lang][0],
                                  m_metaTable[lang][1],
                                  m_metaTable[lang][2]);
    } else {
        scePrintf("%s unsupported language %d\n", __FUNCTION__, lang);
    }
}

void
ezNetCtlSetScfLanguage(void)
{
    ezNetCtlSetLanguage(sceScfGetLanguage());
}

