Created
December 17, 2018 13:41
-
-
Save ankedsgn/9724390249726d642f6447da9da54f8f to your computer and use it in GitHub Desktop.
Bolt + Twig - guess language for 404 page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# | |
Create a user friendly 404 page that guesses the broken link by looking at the language attribute, and serving the appropriate language | |
#} | |
{# Special 404 case, no locales present: check for language #} | |
{% set language = getlanguage()|default(app.request.pathInfo|split("/")[1])|default('nl') %} | |
{% if language == 'en' %} | |
{% set record = record.endata|json_decode %} | |
{% endif %} | |
{# {{dump(locales)}} #} | |
<h1 lang="{{language}}">{{ record.title }}</h1> | |
{% if record.introduction is defined and record.introduction is not empty %} | |
<div lang="{{language}}" class="introduction"> | |
{{ record.introduction|raw }} | |
</div> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment