mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-10-10 22:09:31 +00:00
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:
3 files changed
+1661
-10
No files matched your search
+20
-1
@@ -29,7 +29,26 @@
|
||||
</div>
|
||||
|
||||
{{ 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>
|
||||
(function () {
|
||||
var quotes = JSON.parse({{ $json }});
|
||||
|
||||
Reference in new issue
Block a user