Hide custom guide links depending on language (location)

Answered

5 Comments

  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member - 2022
    Most Engaged Community Member of The Year - 2021

    Hi Michael Jenkins,

    Using this code, you can hide your custom links from other languages and would be shown only in English local. You can use this idea in your script.js file.

     

    Remove "LINK'S CLASS NAME" and add the link's class name, with a dot ( . ) because without dot ( . ) class-name won't work

    e.g. $(" .language-link ")

    or you can use tag-name without dot ( . ) 

    e.g. $(" li > a ")

    $(document).ready(function(){

    var htmllang = document.documentElement.lang;

    // Links are hidden for other languages
    $("LINK'S CLASS NAME").hide();   

    // If language is english
    if (htmllang === "en-US"){

    // Links would be shown now for english
    $("LINK'S CLASS NAME").show();

    }
    });

     

    Hope it helps you.

    Thanks

     

     

    1
  • Michael Jenkins

    I will give that a try, thank you for your help!

    0
  • Michael Jenkins

    This worked. I had to be a bit creative but was able to get it to work. One thing to note, when I replaced the name I had initially forgot the . at the beginning which broke it. In case anyone else runs into an issue.

    $("CLASS-NAME").show();
    $(".CLASS-NAME").show();
    1
  • Nicole Saunders
    Zendesk Community Manager

    So glad you got things working, Michael Jenkins! Thanks for coming back and sharing your note as well. 

    0
  • Ifra Saqlain
    Community Moderator
    Most Engaged Community Member - 2022
    Most Engaged Community Member of The Year - 2021

    @Michael Jenkins, thanks for notifying me of this, now I updated the code for a dot ( . ) for others. And glad to hear that it's working for you.

    1

Please sign in to leave a comment.

Powered by Zendesk