I am having trouble to generate language specific 404 error pages.
We generate language specifc menus and footers for English as German is our base language. This is done by using HubL code in the wrapping module of the contents that should not be visible. Others are generated based on the language. Here is an example for our menu:
{% if (content.slug is string_startingwith "en/") or (content.slug =="en") %}
{% menu "my_menu" site_map_name='Menu EN', overrideable=False, root_type='site_root', flyouts='true', max_levels='2', flow='horizontal', label='Advanced Menu' %}
{% else %}
{% menu "my_menu" site_map_name='Menu German', overrideable=False, root_type='site_root', flyouts='true', max_levels='2', flow='horizontal', label='Advanced Menu' %}
{% endif %}
Strangely, this does not work for our 404 page. Here, the language slug is ignored and the German site is displayed. As the error page is only editable in the design manager, we cannot create a translated version via the Content Editor...
It's peculiar that the referrer appears empty on error pages, especially when other HTTP request variables are accessible. Troubleshooting this might be somewhat like resolving a complex translation issue – it requires pinpointing the specific settings or conditions causing this inconsistency. You might want to double-check the configuration and possibly seek assistance from your platform's support or community for a more precise solution.
Dec 14, 20209:29 AM - edited Dec 14, 20209:30 AM
Key Advisor
Translation of error pages
The content dict doesn't work because system pages aren't technically content in Hubspot, not in the way that web pages/blogs are.
If your language is a subfolder (i.e. mywesbite.com/en/.. etc.) the real, hidden request path for 404 and 500 pages is /content-rendering/v1/public/[language] so you can use "string_containing" instead of "string_startingwith" to detect a translation on system pages or if you need to detect if the page being viewed is an error page and what the language is (e.g. for your navigation) you can do {% if request.path is string_startingwith '/content-rendering/v1/public/' %} like so:
{% if request.path is string_containing '/fr' %}
// do things in French
{% endif %}
// OR
{% if request.path is string_startingwith '/content-rendering/v1/public/' %}
{% set requestArray = request.path|split('/', 5) %}
{% set pageLanguage = requestArray[3] %} // will return the language code e.g. 'fr'
{% endif %}