CMS Development

MatthewShepherd
HubSpot Moderator
HubSpot Moderator

Subscription Preferences Page Header and Footer Language Variants

SOLVE

Hi all,

 

I am trying to create language variants for the header and footer of my subscription preferences template (email_subscription_preferences_page).  This template extends the base.html template, which contains global partials for the header and footer areas of the template.  If I could set different language variants of my subscription preferences page I could set language variants via the global content editor, but as I can't set language variants for this system page (that I know of) is there another way to detect browser language in HubL and perhaps load different translated partial templates based on that language?

Thank you in advance!


Matthew Shepherd

Senior Customer Success Manager

HubSpot

He/Him

linkedin.com/in/matthewshepherd/
https://www.hubspot.com/services/professional
0 Upvotes
1 Accepted solution
MatthewShepherd
Solution
HubSpot Moderator
HubSpot Moderator

Subscription Preferences Page Header and Footer Language Variants

SOLVE

I believe I have found my solution with the following 

    {% set lang = request.headers['accept-language']|split(',') %}
    {% set pblang = lang[0] %} 
    {% if pblang == "cs" %}
      {% global_partial path="../partials/footer_cs.html" %}
    {% elif pblang == "de" %}
      {% global_partial path="../partials/footer_de.html" %}  
    {% else %}
      {% global_partial path="../partials/footer.html" %}
    {% endif %}

 

using this code throughout my template I can pull in different partial templates that match the user's primary browser language.


Matthew Shepherd

Senior Customer Success Manager

HubSpot

He/Him

linkedin.com/in/matthewshepherd/
https://www.hubspot.com/services/professional

View solution in original post

3 Replies 3
Anton
Recognized Expert | Diamond Partner
Recognized Expert | Diamond Partner

Subscription Preferences Page Header and Footer Language Variants

SOLVE

Hi @MatthewShepherd

I've did something like this a while ago:

{% if content.language.languageTag == "en" %}
english navigation
{% elif content.language.languageTag == "de" %}
german navigation
...
{% endif %}

 

Maybe it helps

 

 

best, 

Anton 

Anton Bujanowski Signature
MatthewShepherd
HubSpot Moderator
HubSpot Moderator

Subscription Preferences Page Header and Footer Language Variants

SOLVE

Thanks for your help @Anton 

This variable helps me check the language settings of the page, but as the subscription preferences page is a system page, and I can't use multiple different pages with different language settings for that page, this won't work in this case. I think I need a similar if statement that checks the user's browser language.


Matthew Shepherd

Senior Customer Success Manager

HubSpot

He/Him

linkedin.com/in/matthewshepherd/
https://www.hubspot.com/services/professional
0 Upvotes
MatthewShepherd
Solution
HubSpot Moderator
HubSpot Moderator

Subscription Preferences Page Header and Footer Language Variants

SOLVE

I believe I have found my solution with the following 

    {% set lang = request.headers['accept-language']|split(',') %}
    {% set pblang = lang[0] %} 
    {% if pblang == "cs" %}
      {% global_partial path="../partials/footer_cs.html" %}
    {% elif pblang == "de" %}
      {% global_partial path="../partials/footer_de.html" %}  
    {% else %}
      {% global_partial path="../partials/footer.html" %}
    {% endif %}

 

using this code throughout my template I can pull in different partial templates that match the user's primary browser language.


Matthew Shepherd

Senior Customer Success Manager

HubSpot

He/Him

linkedin.com/in/matthewshepherd/
https://www.hubspot.com/services/professional