Hide a block based on user's browser language

<script>
document.addEventListener("DOMContentLoaded", function () {
    const userLocale = navigator.languages && navigator.languages.length
        ? navigator.languages[0]
        : navigator.language;
    
    if(userLocale.startsWith("en-")) {
        document.getElementById("block-id").style.display = "none";
    }
});
</script>

Note: block-id needs to be replaced with your block id and the en- prefix needs to be replaced with the locale prefix you need to hide the block for.

5 Likes