32 lines
1.6 KiB
HTML
32 lines
1.6 KiB
HTML
{{/*
|
|
lang_switcher — the language switcher, shared by index.html (sidebar
|
|
footer, next to the theme toggle) and every auth.html page. Expects
|
|
a dict with:
|
|
CSRFToken — the page's CSRF token
|
|
Lang — the page's current locale code ("en", "fr", …)
|
|
Next — where SetLanguage should redirect back to after the
|
|
POST; each call site passes its own page path since,
|
|
unlike ConversationID for the theme toggle, there's no
|
|
single field every page that includes this partial has
|
|
in common.
|
|
Deliberately plain <select> + submit button, no auto-submit-on-change
|
|
— the page's Content-Security-Policy has no 'unsafe-inline' in
|
|
script-src (see middleware.go's contentSecurityPolicy), and an
|
|
inline onchange="…" handler is script-src territory, not
|
|
style-src's, so it would be silently blocked by the browser exactly
|
|
the way the project's own htmx allowEval:false note warns about.
|
|
Same no-new-script-dependency stance as the rest of the front end.
|
|
*/}}
|
|
{{ define "lang_switcher" }}
|
|
<form method="post" action="/language" class="lang-switcher" aria-label="{{ t .Lang "nav.language" }}">
|
|
<input type="hidden" name="csrf_token" value="{{ .CSRFToken }}" />
|
|
<input type="hidden" name="next" value="{{ .Next }}" />
|
|
<select name="lang" class="lang-select" aria-label="{{ t .Lang "nav.language" }}">
|
|
{{ range supportedLanguages }}
|
|
<option value="{{ .Code }}"{{ if eq (print .Code) $.Lang }} selected{{ end }}>{{ .Name }}</option>
|
|
{{ end }}
|
|
</select>
|
|
<button type="submit" class="lang-switcher-submit" title="{{ t .Lang "nav.language" }}">✓</button>
|
|
</form>
|
|
{{ end }}
|