Using if statements to only show language switcher url if there is a translated page in HubSpot

Highlighted
Regular Contributor | Diamond Partner

Hi all,

 

Is it possible to have a statement in my language switcher module so that only if there is a translated page in that language available to display that language option in the switcher, if not don't display that language option in the dropdown?

 

Here is my code:

<div class="navbar">
  <div class="dropdown">
    <button class="dropbtn">
     <i class="fa fa-globe"></i>
    </button>
    <div class="language-dropdown-content">
     {% if content.language.langauageTag == "en-us" %} <a href="/{{ content.translated_content['en-us'].slug || '' }}">Americas</a> {% endif %}
     <a href="/{{ content.translated_content['en-gb'].slug || 'en-gb' }}/{{ request.path|split('/', 2)|last }}">EMEA</a>
    </div>
  </div> 
</div>

That if statement isn't working. It's just turning the switcher off on every page.

 

This is the website: https://www.cogencyglobal.com/en-gb/

 

Many thanks!

Reply
0 Upvotes
2 Replies 2
Highlighted
Community Manager

Hey @DanBQ 

 

I apologize for the delay in getting back to you. I will tag a few of our experts to give you some tips about this.           

 

Hey @derekcavaliero @Jsum could you please share your knowledge with @DanBQ          

 

Thank you,

Sharon


Did my post help answer your query? Help the Community by marking it as a solution
Reply
0 Upvotes
Highlighted
Esteemed Advisor | Partner

@DanBQ ,

 

I ran into this problem myself. I searched developer info and all of the docs. As far as I can tell, There is no way to to determine whether a page has translations or not. an ugly solution would be to use the modules html wrapper to check the page name for page's that have translations. something like.

{% if content.name == 'page name 1' or if content.name == 'page name 2' %}
    {{html}}
{% endif %}

Let us know if you find a better solution.