We use cookies to make HubSpot's community a better place. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).
Oct 13, 2021 8:26 AM - edited Oct 13, 2021 8:27 AM
Hi there,
I am currently trying to create a multilingual Subscription Preferences Page.
We already have set up all the translations for email subscription types like shown here: https://knowledge.hubspot.com/contacts/create-translations-for-your-email-subscription-types
After we did that, we see a dropdown menu at the top of the email preferences page to select a translation language.
The page URL has a parameter "languagePreference" which contains the language code. This language, if available, is also selected directly in the DropDown.
Now I want to display further content based on this language. To do this, however, I need to be able to read out the parameter value.
The Hubl variable request.query does not return the given url, so no languagePreference parameter available. If I do that with javascript location.search I get the right URL containing the parameter languagePreference. But since I can't use Javasript variables in Hubl, I need to find the right Hubl variable to retriev the languagePreference value.
request.query result: portalId=9311353&email=fischer%40nextage.ch
In the page source code I see a javascript function replaceLangPrefWith handels the language dropdown. I need to know which Hubl variable is used to set the default language: var currentLangPref = "? HUBL VARIABLE ?";
It would be super if someone could help me here!
Oct 16, 2021 3:24 PM
Oct 14, 2021 1:32 PM
Have either of you worked with this issue before?
![]() | Make sure to subscribe to our YouTube channel where you can find the HubSpot Community Developer Show |
Oct 18, 2021 9:08 AM
Hi @MFischer,
the language is set in the crm right?
If so you could set it up like this. In this example I'll give the crm property the name "language".
currentLangPref = "?contact.language?";
best,
Anton
![]() | Did my post help answer your query? Help the Community by marking it as a solution |
Oct 18, 2021 9:35 AM
Hi @Anton
The language of each contact is set within the crm: contact.hs_language. This value I get easily.
But the languagePreference parameter is set by the language of the email.
Now, it is theoretically possible for a French speaker to receive an English newsletter. Not nice but possible.
The dropdown and thus the subscriptions are displayed in the language of the newsletter. But since I can't query this language, the rest of the page would be in French (contact.hs_language). Also, I don't see any way to change the default language of the dropdown without refreshing the page.
It would be easiest if I could display the entire content of the page in the language from the languagePreference parameter. But for that I have to be able to read this parameter first.
Thanks anyway,
Michèle