Skip to content

Commit

Permalink
Finish 404 page for multi-lingual
Browse files Browse the repository at this point in the history
  • Loading branch information
Jieiku committed May 26, 2023
1 parent b978e20 commit a0c7ba1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ Tags = "Mots-clés"
Contact = "Contact"
Privacy = "Confidentialité"
Sitemap = "Plan du site"
### Page not found, maybe moved or not in this language
404_not_found = "Page introuvable, peut-être déplacée ou non dans cette langue"
### Try searching or
404_try_search = "Essayez de rechercher ou"
### go to homepage
404_go_home = "allez à la page d'accueil"

#[languages.es.translations]
#flag = "🇪🇸"
Expand Down
11 changes: 9 additions & 2 deletions templates/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@
{%- block content %}
<div>
<h1>404 :(</h1>
<p>The page you are looking for doesn't exist or has been moved. Try using the search, or <a href="{{ config.base_url | safe }}/{%- if config.extra.uglyurls %}index.html{%- endif %}">go home</a>.</p>
<p>La page que vous recherchez n'existe pas ou a été déplacée. Essayez d'utiliser la recherche, ou <a href="{{ config.base_url | safe }}/fr/{%- if config.extra.uglyurls %}index.html{%- endif %}">rentrez chez vous</a>.</p>
{#- Default English message #}
<p>Page not found, maybe moved{% if config.languages | length > 0 %} or not in this language{% endif %}. {% if config.build_search_index %}Try searching or{% endif %} <a href="{{ config.base_url | safe }}/{%- if config.extra.uglyurls %}index.html{%- endif %}">go to homepage</a>.</p>

{# Iterate through each language and display the localised 404 message #}
{%- for language_name, language in config.languages -%}
{%- if language_name != config.default_language -%}
<p>{{ trans(key="404_not_found", lang=language_name) }}. {% if config.build_search_index %}{{ trans(key="404_try_search", lang=language_name) }}{% endif %} <a href="{{ config.base_url }}/{{ language_name }}/{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ trans(key="404_go_home", lang=language_name) }}</a>.</p>
{%- endif -%}
{%- endfor -%}
</div>
{%- endblock content %}

1 comment on commit a0c7ba1

@Jieiku
Copy link
Owner Author

@Jieiku Jieiku commented on a0c7ba1 May 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot that I hard coded the translation for french while prototyping the multilingual feature. I was looking over welpo/tabi#80 because it was linked to an issue in abridge, which reminded me to finish the 404 page, some code from tabi was used and adapted for the 404 page in abridge.

Please sign in to comment.