CMS Development

JanekNahm
Contributor | Diamond Partner
Contributor | Diamond Partner

Translation of error pages

Hi there,

 

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... 

 

"English" version: https://www.divia.de/en/ichwilltetrisspielen

Standard version in German: https://www.divia.de/ichwilltetrisspielen

 

Does anybody have a solution for that? 

 

Thanks in advance!

 

Kind regards,
Janek 

 

 

 

8 Replies 8
TDonnelly
Member

Translation of error pages

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.

0 Upvotes
piersg
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 %}

 

stefen
Key Advisor | Partner
Key Advisor | Partner

Translation of error pages

I wonder if you could use the {{ request.referrer }} variable in the 404 template to display the correct language as a possible work-a-round:

{% if request.referrer is string_startingwith "en/" %}

Worth a try I suppose.

Stefen Phelps, Community Champion, Kelp Web Developer
JanekNahm
Contributor | Diamond Partner
Contributor | Diamond Partner

Translation of error pages

Hi Stefen,

Thanks for the hint! 

 

Sadly, this does not work. The referrer is empty on error pages. This is strage as I was able to print other http request variables on the page:

<p>{{ request.scheme }}</p>

 

Best,

Janek

0 Upvotes
Dallas_Antwerp
Contributor

Translation of error pages

Where could i find the (detailed) documentation about hubl code like this:

{% if (content.slug is string_startingwith "en/") or (content.slug =="en") %
<p>{{ request.scheme }}</p>
{% if request.referrer is string_startingwith "en/" %} 

Thanks

0 Upvotes
JulienNeoptimal
Participant

Translation of error pages

@JanekNahm  Do you have found a solution ? me too the variables doesn't function on 404 page.

0 Upvotes
Dallas_Antwerp
Contributor

Translation of error pages

Thanks

0 Upvotes