const DEFAULT_LANGUAGE = 'en';
const SUPPORTED_LANGUAGES = ['ro', 'en', 'fr', 'ar', 'hr'];
const TRANSLATIONS = {
    en: {
        error: 'Error',
        backButton: 'Back',
        lobbyButton: 'Lobby',
        nextDraw: 'Next draw in: ',
        buy: 'Buy tickets',
        viewLatest: 'View latest results',
        submitSuccess: 'Submit successfully!',
        orderSummaryTitle: 'Order Summary',
        orderSummaryTickets: 'Ticket',
        orderSummaryTotal: 'Total',
        orderSummarySubmit: 'Submit',
        modalLogin: 'Please login to submit a ticket',
        loading: 'Loading, please wait ...',
    },
    ro: {
        error: 'Eroare',
        backButton: 'Inapoi',
        lobbyButton: 'Lobby',
        nextDraw: 'Urmatoarea extragere:',
        buy: 'Cumpara bilet',
        viewLatest: 'Ultimile extrageri',
        submitSuccess: 'Submit successfully!',
        orderSummaryTitle: 'Rezumat comanda',
        orderSummaryTickets: 'Bilet',
        orderSummaryTotal: 'Total',
        orderSummarySubmit: 'Trimite',
        modalLogin: 'Please login to submit a ticket',
        loading: 'Se incarca, va rugam asteptati ...',
    },
    fr: {
        error: 'Error',
        backButton: 'Back',
        lobbyButton: 'Lobby',
        nextDraw: 'Next draw in: ',
        buy: 'Buy tickets',
        viewLatest: 'View latest results',
        submitSuccess: 'Submit successfully!',
        orderSummaryTitle: 'Order Summary',
        orderSummaryTickets: 'Ticket',
        orderSummaryTotal: 'Total',
        orderSummarySubmit: 'Submit',
        modalLogin: 'Please login to submit a ticket',
        loading: 'Loading, please wait ...',
    },
    ar: {
        error: 'خطأ',
        backButton: 'خلف',
        lobbyButton: 'ردهة',
        nextDraw: 'السحب التالي:',
        buy: 'اشتري تذاكر',
        viewLatest: 'عرض أحدث النتائج',
        submitSuccess: 'Submit successfully!',
        orderSummaryTitle: 'ملخص الطلب',
        orderSummaryTickets: 'تذكرة',
        orderSummaryTotal: 'المجموع',
        orderSummarySubmit: 'يُقدِّم',
        modalLogin: 'الرجاء تسجيل الدخول لتقديم تذكرة',
        loading: 'Loading, please wait ...',
    },
    hr: {
        error: 'Greška',
        backButton: 'Nazad',
        lobbyButton: 'Lobby',
        nextDraw: 'Sljedeće izvlačenje za: ',
        buy: 'Uplati listić',
        viewLatest: 'Pogledajte najnovije rezultate',
        submitSuccess: 'Submit successfully!',
        orderSummaryTitle: 'Sažetak narudžbe',
        orderSummaryTickets: 'Listić',
        orderSummaryTotal: 'Ukupno',
        orderSummarySubmit: 'Podnijeti',
        modalLogin: 'Molimo prijavite se da uplatite listić',
        loading: 'Učitavanje, molimo pričekajte ...',
    }
};
export const translate = (key, customLang) => {
    const lang = customLang;
    return TRANSLATIONS[lang !== undefined && SUPPORTED_LANGUAGES.includes(lang) ? lang : DEFAULT_LANGUAGE][key];
};
export const getTranslations = (url) => {
    return new Promise((resolve, reject) => {
        fetch(url)
            .then((res) => res.json())
            .then((data) => {
            Object.keys(data).forEach((item) => {
                for (let key in data[item]) {
                    TRANSLATIONS[item][key] = data[item][key];
                }
            });
            resolve(TRANSLATIONS);
        }).catch(err => {
            reject(err);
        });
    });
};
