i18n: instant lang switch via HTMX trigger + refresh paid-plans terms

This commit is contained in:
Giorgio Gilestro 2026-05-27 21:02:03 +02:00
parent f4d9c9f2ec
commit e4dc6d0071
4 changed files with 22 additions and 25 deletions

View file

@ -158,12 +158,14 @@
body: JSON.stringify({lang: newLang}), body: JSON.stringify({lang: newLang}),
}); });
if (!r.ok) throw new Error('HTTP ' + r.status); if (!r.ok) throw new Error('HTTP ' + r.status);
// Reload localized panels so the user immediately sees content // Trigger HTMX-driven panels to re-fetch in the new language.
// in the new language (strategic log, dashboard header, etc.). // Same shape as cassandraSetTone — every panel that listens to
if (window.location.pathname === '/log' || // tone-changed also listens to lang-changed.
window.location.pathname.startsWith('/log/')) { ['#dash-header-container', '#log-panel .panel-body',
window.location.reload(); '#indicators-body', '#log-content'].forEach(function (sel) {
} var el = document.querySelector(sel);
if (el && window.htmx) window.htmx.trigger(el, 'lang-changed');
});
} catch (e) { } catch (e) {
pill.dataset.lang = prev; pill.dataset.lang = prev;
console.warn('language switch failed:', e); console.warn('language switch failed:', e);

View file

@ -5,7 +5,7 @@
<div id="dash-header-container" <div id="dash-header-container"
style="grid-column: 1 / -1;" style="grid-column: 1 / -1;"
hx-get="/api/summary/aggregate?as=html" hx-get="/api/summary/aggregate?as=html"
hx-trigger="load, every 300s, tone-changed" hx-trigger="load, every 300s, tone-changed, lang-changed"
hx-swap="innerHTML"> hx-swap="innerHTML">
<div class="empty">loading aggregate read…</div> <div class="empty">loading aggregate read…</div>
</div> </div>
@ -29,7 +29,7 @@
<div id="indicators-body" <div id="indicators-body"
class="panel-body panel-body--scroll" class="panel-body panel-body--scroll"
hx-get="/api/indicators/{{ groups[0] }}?as=html" hx-get="/api/indicators/{{ groups[0] }}?as=html"
hx-trigger="load, tone-changed" hx-trigger="load, tone-changed, lang-changed"
hx-swap="innerHTML"> hx-swap="innerHTML">
<div class="empty">loading…</div> <div class="empty">loading…</div>
</div> </div>
@ -115,7 +115,7 @@
</div> </div>
<div class="panel-body" <div class="panel-body"
hx-get="/api/log/latest?as=html" hx-get="/api/log/latest?as=html"
hx-trigger="load, every 300s, tone-changed" hx-trigger="load, every 300s, tone-changed, lang-changed"
hx-swap="innerHTML"> hx-swap="innerHTML">
<div class="empty">awaiting first log…</div> <div class="empty">awaiting first log…</div>
</div> </div>

View file

@ -25,7 +25,7 @@
<article id="log-content" <article id="log-content"
class="log-page__content" class="log-page__content"
hx-get="/api/log/by-date/{{ selected_iso }}?as=html" hx-get="/api/log/by-date/{{ selected_iso }}?as=html"
hx-trigger="load, tone-changed" hx-trigger="load, tone-changed, lang-changed"
hx-swap="innerHTML"> hx-swap="innerHTML">
<div class="empty">loading log…</div> <div class="empty">loading log…</div>
</article> </article>

View file

@ -77,21 +77,16 @@
<section class="public-section"> <section class="public-section">
<h2 class="public-section__head">5. Paid plans</h2> <h2 class="public-section__head">5. Paid plans</h2>
<p> <p>
If and when paid plans become available, you will be told the Paid plans are available at &pound;7/month or &pound;70/year (terms
applicable fees at point of sale. Paid features remain active for as and current prices on the <a href="/pricing">pricing page</a>). New
long as the subscription is current or any time-bounded credit annual subscriptions begin with a 14-day free trial; monthly
granted to your account is still valid. You can cancel a paid subscriptions begin immediately on payment. Paid features remain
subscription at any time; cancellation takes effect at the end of active for as long as the subscription is current or any
the current billing period unless otherwise stated. time-bounded credit granted to your account is still valid. You
</p> can cancel a paid subscription at any time; cancellation takes
<p> effect at the end of the current billing period unless otherwise
Where the law gives you a 14-day right to cancel a subscription stated. Detailed refund and cancellation rights are set out in
(Consumer Contracts (Information, Cancellation and Additional section 6 below.
Charges) Regulations 2013, UK), that right applies. By starting to
use a paid feature immediately on purchase you agree we may begin
supplying the service within the cancellation period, and you
acknowledge that you lose the right to cancel in respect of any
digital content already delivered.
</p> </p>
</section> </section>