From 42a43ff0d1d338e4b8a8d81b9a67fa925abaea25 Mon Sep 17 00:00:00 2001 From: Alexander Borsuk Date: Tue, 3 Nov 2026 18:56:24 +0100 Subject: [PATCH 01/10] Fix language declarations in navigation and donation fallbacks Declare fallback menu labels and checkout text in their source language while retaining the donation page language for payment return URLs. Resolve donation companions directly in the active language with a strict default-language fallback, and use full resources' root-relative paths for internal links. Exercise the real checkout form with translated companions and slugs, missing default resources, inherited menu, heading and form languages, and an independent payment language. Document the lookup rules and regression command. Signed-off-by: Alexander Borsuk --- .github/copilot-instructions.md | 5 +- templates/_donate_form.html | 2 +- templates/donate-subscribe.html | 7 +- templates/donate.html | 9 +- templates/top_menu.html | 2 +- tools/test_navigation.py | 147 ++++++++++++++++++++++---------- 6 files changed, 116 insertions(+), 56 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index d74aa776d..c1dbf2c37 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -76,6 +76,7 @@ Use `{{ trans(key='faq-menu-title', lang=lang) }}` to get localized strings from zola serve # Live preview at http://127.0.0.1:1111 zola build # Generate static site in public/ npm test # Offline translation, hook and Telegram regressions +python3 tools/test_navigation.py # Navigation and donation language fallbacks (requires Zola) npm run test:browser # Donation checkout regressions against public/ (build first) npm run format # Format MD + SCSS (stylelint + prettier + js-beautify) npm run upgrade # Update npm dependencies @@ -167,7 +168,9 @@ hook, the test suite — adds `tools/` to `sys.path` explicitly. - Top menu built dynamically in `templates/top_menu.html` - Reads pages via `get_section()` and `get_page()` -- Finds translations via `[t for t in page.translations if t.lang == lang] | first` because Tera v2 has no `filter` filter +- The top menu looks up each destination with `lang=lang, allow_missing=true`, then strictly loads the default-language resource if its translation is absent. Missing required default resources stop the build. +- The bottom menu selects translations from the default-language inventory via `[t for t in page.translations if t.lang == lang] | first` because Tera v2 has no `filter` filter. +- Top-menu fallback links and donation checkout text declare the selected resource's language so assistive technology can pronounce them correctly. The checkout API still receives the donation page's language for its return URLs. - Menu titles from `extra.menu_title` in content frontmatter ### Styling diff --git a/templates/_donate_form.html b/templates/_donate_form.html index 3471fa3f3..689d139a2 100644 --- a/templates/_donate_form.html +++ b/templates/_donate_form.html @@ -97,5 +97,5 @@ data-label-once="{{ f.submit_once }}" data-label-month="{{ f.submit_month }}" data-label-year="{{ f.submit_year }}" data-label-loading="{{ f.submit_loading }}">{{ f.submit }} - + diff --git a/templates/donate-subscribe.html b/templates/donate-subscribe.html index aa73f177e..9232fd4a2 100644 --- a/templates/donate-subscribe.html +++ b/templates/donate-subscribe.html @@ -10,9 +10,10 @@ {% block content %} {% set f = resource.extra.form %} {# The main donation page may be untranslated even when this landing page exists. #} -{% set donate = get_page(path="donate/index.md", lang=config.default_language) %} -{% set translated = [t for t in donate.translations if t.lang == lang] | first %} -{% if translated %}{% set donate = translated %}{% endif %} +{% set donate = get_page(path="donate/index.md", lang=lang, allow_missing=true) %} +{% if not donate %} + {% set donate = get_page(path="donate/index.md", lang=config.default_language) %} +{% endif %} {% set return_to = "subscribe" %}