25 lines
1.3 KiB
Plaintext
25 lines
1.3 KiB
Plaintext
<%#
|
|
Language picker: one link per installed locale, each pointing at this same page with ?locale set,
|
|
so switching is a plain navigation — zero-JS, and the address bar always says which language the
|
|
page is in. Renders nothing for a single-language deployment.
|
|
Locals: localeSwitch (host-supplied: { current, href, label, tag }[]) · up? (open upward, default true)
|
|
localeMenuId? (the menu's id; name a second picker on the same page. Not `id` — EJS
|
|
merges page locals into every include, and `id` is the likeliest key in a plugin's data)
|
|
-%>
|
|
<% const choices = locals.localeSwitch || []; -%>
|
|
<% if (choices.length > 1) { -%>
|
|
<%- include("menu", {
|
|
id: locals.localeMenuId || "locale-menu",
|
|
align: null, kebab: false, width: null, // explicit: EJS would otherwise inherit the page's own
|
|
up: locals.up !== false,
|
|
trigger: { class: "btn icon-btn", icon: "i-globe", label: t("locale.label") },
|
|
items: [
|
|
{ head: t("locale.label") },
|
|
...choices.map((c) => ({ current: c.current, href: c.href, hreflang: c.tag, label: c.label, ownLocale: true })),
|
|
// This page can't be re-rendered in another language (its URL answers no GET), so switching
|
|
// navigates away — and may leave a one-time secret behind. Say it before the click.
|
|
...(locals.leavesPage ? [{ head: t("locale.leavesPage") }] : []),
|
|
],
|
|
}) %>
|
|
<% } -%>
|