Hide languages from the language selector

Answered

1 Comments

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

    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

Please sign in to leave a comment.

Powered by Zendesk