How to Add Language Code Next to HubSpot Language Dropdown


How to Add Language Code Next to HubSpot Language Dropdown

By default, when you visit a page with a translation, it displays a globe icon. I thought it would be more helpful to have a visual cue for your current language. So I wrote the code below to add the current language code next to the globe icon.

Table of Contents

Javascript

Add this to your main theme javascript file.

// if the language dropdown exists on the page
if( $('#languageTemplate').length ) {
    // get the html language and languages list
    const $languageUL = $('#languageTemplate .lang_list_class');
    const $theLanguage = $('html').attr('lang');

    // if the anchor link matches the document language make it active
    $( $languageUL ).find("a").each(function() {
        if ($(this).data('language') === $theLanguage) {
            $(this).addClass('active-item');
        }
    });

    // Append the language code next to the globe class
    $('#languageTemplate .globe_class').append('<div class="langdigit">'+$theLanguage+'</div>');
// translation exists
}

CSS

Add this to your main theme css file.

#languageTemplate {
  margin-right: 25px;
}

#languageTemplate > span{
  display:block;
  height:20px;
}

#languageTemplate .langdigit {
  position: relative;
  right: -15px;
  padding: 0 0 0 10px;
  font-size:14px;
}

 

About the Author

Jake Lett is a results-driven Detroit based B2B marketing consultant with 15+ years of hands-on experience managing SEO and PPC campaigns across manufacturing, SaaS, and professional services industries. He’s a Certified Google Ads Specialist and HubSpot CMS Developer who has personally managed budgets ranging from $500 to over $10,000/month.

Jake specializes in helping small businesses and solo marketers get more from lean ad budgets—using practical strategies that drive qualified leads, not just traffic. He shares real-world lessons on his blog, YouTube channel, and in his published books on digital marketing.



Related posts

Tags: ,

Want to Get Email Updates of New Articles?

Join My Email Newsletter