Template edits based on language

1 Comments

  • Ifra Saqlain
    Community Moderator

    Hi @Anthony Hopkins, 

    Check the language with the if condition and hide the div and container you want.

    See how I did:

    1). I added a div on home_page.hbs with some special content.

    2). Add a class-name in main parent wrapper of that added parent div - div-main-wrapper.

    3). Now, it would be hidden on all languages and shown only on English language.

    4). Copy and paste it into script.js file at the bottom area.

    $(document).ready(function(){
    var htmllang = document.documentElement.lang;

    // div-main-wrapper - my parent wrapper class which is hidden on all languages
    $('.div-main-wrapper').hide();

    // when my HC language would be English, the parent wrapper would be show
    if (htmllang === "en-US"){

    // show any div and container
    $('.div-main-wrapper').show();

    }
    });

     

     

    // Hiding div-main-wrapper - my parent wrapper class which is hidden on all languages
    $('.div-main-wrapper').hide();

    // Checking the language, if my HC language would be English the parent wrapper would be shown
    if (htmllang === "en-US"){

    $('.div-main-wrapper').show();

    }

     

    5). Remove the class-name div-main-wrapper and add your div class-name which you want to show and hide.

    Your div class would be different therefore you can replace that with the class name -  div-main-wrapper

     

    6). Don't forget to add jQuery CDN on document_head.hbs file.

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

     

    If any query do let me know :)

    Team

     

    0

Please sign in to leave a comment.

Powered by Zendesk