Hide custom guide links depending on language (location) | Community
Skip to main content

Hide custom guide links depending on language (location)

  • February 10, 2022
  • 5 replies
  • 0 views

Michael69

We are releasing new language support for our app and help center. However, we have a customized Guide theme with direct links on the landing page of our Guide but it links to the English version and we don't want other languages having that options.

So we are trying to come up with some logic that says, if English then show links, if not then hide. 

That is the basic idea behind it.

5 replies

Ifra
  • February 11, 2022

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

 

 


Michael69
  • Author
  • February 11, 2022

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


Michael69
  • Author
  • February 14, 2022

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();

Nicole17
  • February 14, 2022

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


Ifra
  • February 15, 2022

@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.