Hide languages from the language selector

Answered


Posted Sep 02, 2021

We will activate two new languages in our web soon, so my team is translating all the articles so we could release our Help Center for those languages.
At the time being, when activating a new language in Guide it is visible to end users and can be selected on the language selector.

We want to activate the new languages but keep these hidden from the selector in orden to be able to schedule all the content for the day they will released. I've asked the ZenDesk Support for help but have not been given any answer or information to solve my problem.

To avoid end users land in an empty Help Center if they select one of those new languages I've thought the best option is to hide those locales directly from the design (code). 
We use the default design, can anyone here give us more information or an example of the code that allow us to hide the selected locales from the selector dropdown?

Many thanks!


1

1

1 comment

Hi @Sandra Lefort,  you can hide the selected languages from the language selector using the below code.

Follow the steps:

1). Copy and paste it into your script.js file at the end of all code/bottom area.

// Hide particular language in language selector
var hideLanguageLinkByLocale = function(elements, localeId){
if(elements.length) {
elements.each(function(){
var link = $(this);
var href = link.prop("href");
if(new RegExp("/hc/change_language/" + localeId).test(href)){
link.hide();
}
});
}
}

hideLanguageLinkByLocale($(".dropdown.language-selector a"), "zh-hk"); //Add the lanaguage symbol here
hideLanguageLinkByLocale($(".dropdown.language-selector a"), "en-us"); //Add the lanaguage symbol here

 

Screenshot for the same:

 

You are seeing the line -

hideLanguageLinkByLocale($(".dropdown.language-selector a"), "en-us");

 

".dropdown.language-selector a" - It's for language selector anchor tag.

"en-us" - It's your language you want to hide at that time. It's default language, you can change it like zh-hk, zh-tw etc. 

 

When you select your new language from the language selector, you will get the language symbol in the searchbar:

zh-hk -

 

en-us -

 

copy the language symbol from the search-bar and paste it in the script code as I told above. And when you are going to release the content with the new languages, remove this added code from the script.js file.

 

Reference taken from here.

Thanks

 

1


Sign in to leave a comment.

Didn't find what you're looking for?

New post