function translate(lang) {
    // lang will be its id, which is the language chosen
    // searches for all items with class="lang" and changes its text to the one associated within their "key" to the variable arrLang
    let texts = document.getElementsByClassName('lang')
    let translation = arrLang[lang]
    Array.prototype.forEach.call(texts, item => {
        item.innerHTML = translation[item.id]
    })

    // Traduce los titulos de las paginas
    let page = window.location.pathname.split("/").pop();
    document.title = translation[page];
    
    // Traduce las excepciones como placeholders que no pueden accederse con el metodo anterior
    let inputs = document.getElementsByTagName("input");
    Array.prototype.forEach.call(inputs, item => {
        if(page == "login.html") {
            item.placeholder += translation[item.id];
        } else {
            item.placeholder = translation[item.id];
        } 
    })
    let options = document.getElementsByTagName("option");
    Array.prototype.forEach.call(options, item => {
        if(page != 'weather.html') {
            item.innerHTML = translation[item.id];
        }
    })
    
    // Cierra el tooltip
    const tooltip = document.getElementById('lang-selector');
    tooltip.style.display = "none";
}
// In a separate function for code clarity

In a separate function for code clarity
In a separate function for code clarity
function translate(lang) {
    let texts = document.getElementsByClassName('lang')
    let translation = arrLang[lang]
    Array.prototype.forEach.call(texts, item => {
        item.innerHTML = translation[item.id]
    })
    let page = window.location.pathname.split("/").pop();
    document.title = translation[page];
    let inputs = document.getElementsByTagName("input");
    Array.prototype.forEach.call(inputs, item => {
        if(page == "login.html") {
            item.placeholder += translation[item.id];
        } else {
            item.placeholder = translation[item.id];
        } 
    })
    let options = document.getElementsByTagName("option");
    Array.prototype.forEach.call(options, item => {
        if(page != 'weather.html') {
            item.innerHTML = translation[item.id];
        }
    })
    const tooltip = document.getElementById('lang-selector');
    tooltip.style.display = "none";
}
function translate ( lang ) { let texts = document . getElementsByClassName ( 'lang' ) let translation = arrLang [ lang ] Array . prototype . forEach . call ( texts , item => { item . innerHTML = translation [ item . id ] } ) let page = window . location . pathname . split ( "/" ) . pop ( ) ; document . title = translation [ page ] ; let inputs = document . getElementsByTagName ( "input" ) ; Array . prototype . forEach . call ( inputs , item => { if ( page == "login.html" ) { item . placeholder += translation [ item . id ] ; } else { item . placeholder = translation [ item . id ] ; } } ) let options = document . getElementsByTagName ( "option" ) ; Array . prototype . forEach . call ( options , item => { if ( page != 'weather.html' ) { item . innerHTML = translation [ item . id ] ; } } ) const tooltip = document . getElementById ( 'lang-selector' ) ; tooltip . style . display = "none" ; }
In a separate function for code clarity
In a separate function for code clarity
// lang will be its id, which is the language chosen
 // searches for all items with class="lang" and changes its text to the one associated within their "key" to the variable arrLang
 // Traduce los titulos de las paginas
 // Traduce las excepciones como placeholders que no pueden accederse con el metodo anterior
 // Cierra el tooltip
