From b25385f7313edce6191a038dc906d88d6b26c7a3 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 17 Apr 2026 11:56:14 +0200 Subject: fix: detect language server-side in 404 template for proper translations Added language detection at template level to determine language from permalink and build translation dictionary. All i18n strings now use language-aware translations instead of relying on .Lang context which isn't available in 404 handler. Co-Authored-By: Claude Haiku 4.5 --- themes/danix-xyz-hacker/layouts/404.html | 61 +++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 13 deletions(-) (limited to 'themes') diff --git a/themes/danix-xyz-hacker/layouts/404.html b/themes/danix-xyz-hacker/layouts/404.html index 341f90b..9b50b44 100644 --- a/themes/danix-xyz-hacker/layouts/404.html +++ b/themes/danix-xyz-hacker/layouts/404.html @@ -1,5 +1,40 @@ {{ define "main" }} +{{ $lang := "en" }} +{{ if in .Permalink "/it/" }} + {{ $lang = "it" }} +{{ end }} + +{{ $translations := dict "en" (dict + "notFound" "Page Not Found" + "notFoundMessage" "Sorry, the page you're looking for doesn't exist. Try searching or browse the articles below." + "searchPlaceholder" "Search articles..." + "noSearchResults" "No articles found matching your search." + "recentArticles" "Recent Articles" + "goHome" "Go Home" + "browseArticles" "Browse Articles" + "contactSupport" "Get in Touch" + "followWhiteRabbit" "Follow the white rabbit..." + "easterEggTitle" "Choose Your Path" + "bluePill" "Stay Here" + "redPill" "Show Me More" +) "it" (dict + "notFound" "Pagina Non Trovata" + "notFoundMessage" "Mi dispiace, la pagina che stai cercando non esiste. Prova a cercare o sfoglia gli articoli qui sotto." + "searchPlaceholder" "Cerca articoli..." + "noSearchResults" "Nessun articolo trovato che corrisponda alla tua ricerca." + "recentArticles" "Articoli Recenti" + "goHome" "Torna a Casa" + "browseArticles" "Sfoglia Articoli" + "contactSupport" "Contattami" + "followWhiteRabbit" "Segui il coniglio bianco..." + "easterEggTitle" "Scegli il Tuo Percorso" + "bluePill" "Rimani Qui" + "redPill" "Mostrami di PiΓΉ" +) }} + +{{ $t := index $translations $lang }} +