Feb 12, 2021 11:35 AM
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 ShepherdSenior Customer Success Manager HubSpot He/Him |
|
Solved! Go to Solution.
Feb 16, 2021 7:57 AM
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 ShepherdSenior Customer Success Manager HubSpot He/Him |
|
Feb 12, 2021 12:01 PM
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
Feb 16, 2021 7:05 AM
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 ShepherdSenior Customer Success Manager HubSpot He/Him |
|
Feb 16, 2021 7:57 AM
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 ShepherdSenior Customer Success Manager HubSpot He/Him |
|