I'm working on a site with multilingual support.
I have a few divs with the same content in multiple languages, and I'm showing the content depending on the language of the users client.
Everything works, but I get an Error which says
Uncaught TypeError: Cannot read property 'style' of null at mywebsite.html
The error points to the case which is displayed.
How can I get rid of the error?
var language = navigator.language || navigator.languages[0];
console.log(language);
var languageFistTwo = language.substr(0,2); // To only keep the first 2 characters.
console.log(languageFistTwo);
switch (languageFistTwo) {
    case "sl":
        document.getElementById("sl").style.display="inline-block";
        break;  
    case "en":
        document.getElementById("en").style.display="inline-block";
        break;
    case "de":
        document.getElementById("de").style.display="inline-block";
        break;
    case "it":
        document.getElementById("it").style.display="inline-block";
        break;
    case "hr":
        document.getElementById("hr").style.display="inline-block";
        break;
    case "ru":
        document.getElementById("ru").style.display="inline-block";
        break;
    default:
        document.getElementById("en").style.display="inline-block";
}#sl {
    display: none;
}
#en {
    display: none;
}
#de {
    display: none;
}
#it {
    display: none;
}
#hr {
    display: none;
}
#ru {
    display: none;
}<div id="sl">
Zdravo
</div>
<div id="en">
Hello
</div>
<div id="de">
Gutten Tag
</div> 
     
     
     
    