feat: localize 404 page quotes (#3052)

* feat: localize 404 page quotes

* 🐛 Fix 404 quote localization: build-time filtering and dub lines

Filter quotes to the page language at build time (case-insensitive,
with base-language and English fallbacks), fixing the double-encoded
language variable that made every locale fall back to English, and
correct several translations to their canonical dub lines.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Friday <friday@openclaw.local>
Co-authored-by: Nuno Coração <nunocoracao@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
authored and GitHub committed 2026-08-18 21:53:12 +01:00
1 parent 7bef4bb360
commit 03443c989f
3 files changed
+1661 -10

No files matched your search

+1620 -9
View File
File diff suppressed because it is too large. Load diff
@@ -58,6 +58,27 @@ Blowfish was built so it would be easy to add visual support to your articles. I
Blowfish is optimised for full multilingual websites and theme assets are translated into several languages out of the box. The language configuration allows you to generate multiple versions of your content to provide a customised experience to your visitors in their native language. Blowfish is optimised for full multilingual websites and theme assets are translated into several languages out of the box. The language configuration allows you to generate multiple versions of your content to provide a customised experience to your visitors in their native language.
### 404 page quotes
The 404 page displays a random movie quote in the active site language. You can replace the bundled quotes by adding a `data/quotes404.json` file to your site. Each item needs a `line` and `source`; use `lang` to target a language. Language codes may be full codes such as `pt-PT` or base codes such as `pt`. Quotes without `lang` are treated as English for backwards compatibility.
```json
[
{
"lang": "en",
"line": "You shall not pass!",
"source": "The Fellowship of the Ring (2001)"
},
{
"lang": "pt-PT",
"line": "Não passarás!",
"source": "The Fellowship of the Ring (2001)"
}
]
```
Blowfish tries an exact language match, then the base language, then English. If none are available, it selects from any configured quote.
The theme currently supports the following languages by default: The theme currently supports the following languages by default:
| Language | Code | | Language | Code |
+20 -1
View File
@@ -29,7 +29,26 @@
</div> </div>
{{ with hugo.Data.quotes404 }} {{ with hugo.Data.quotes404 }}
{{ $json := . | jsonify }} {{/* Pick the current language's quotes at build time: exact locale
first, then base language, then English. Quotes without a lang are
treated as English to preserve existing custom overrides. */}}
{{ $lang := lower site.Language.Lang }}
{{ $base := index (split $lang "-") 0 }}
{{ $localized := slice }}
{{ $english := slice }}
{{ range . }}
{{ $qlang := lower (.lang | default "en") }}
{{ if or (eq $qlang $lang) (eq $qlang $base) }}
{{ $localized = $localized | append . }}
{{ end }}
{{ if eq $qlang "en" }}
{{ $english = $english | append . }}
{{ end }}
{{ end }}
{{ $quotes := $localized }}
{{ if not $quotes }}{{ $quotes = $english }}{{ end }}
{{ if not $quotes }}{{ $quotes = . }}{{ end }}
{{ $json := $quotes | jsonify }}
<script> <script>
(function () { (function () {
var quotes = JSON.parse({{ $json }}); var quotes = JSON.parse({{ $json }});