mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-06-01 21:14:49 +00:00
5ca3463bf6
Full rewrite of the docs site under app/[locale]/ with next-intl in localePrefix:"always" mode. Every page now exists at both /en/<path> and /es/<path>; the root / shows a meta-refresh + JS redirect to /<defaultLocale>/ so GitHub Pages serves something on the apex URL. Highlights: - 107 doc pages migrated to file-per-page JSON namespaces under messages/en/ and messages/es/. Spanish content is fully translated (no copy-of-English placeholders). - New documentation for the Active Suppressions section in the Settings tab and the per-event Dismiss dropdown in the Health Monitor modal. - New screenshots: dismiss-duration-dropdown.png and an updated health-suppression-settings.png. - Pagefind integrated for client-side search; index is built on every CI deploy (not committed). - RSS feeds: per-locale at /<locale>/rss.xml plus root /rss.xml for backward compat. - Removed the dead app/[locale]/guides/[slug]/ route — every guide now has its own static page and no markdown source remains. - Fixed orphan link /guides/nvidia -> /guides/nvidia-manual in docs/hardware/nvidia-host. - Removed obsolete components (footer2, calendar, drawer). Verified locally with `npm ci && npm run build`: 2804 files in out/, 231 pages indexed by pagefind, root redirect intact, both locale roots and the new Active Suppressions docs render OK.
64 lines
1.9 KiB
TypeScript
64 lines
1.9 KiB
TypeScript
import { hasLocale } from "next-intl"
|
|
import { getRequestConfig } from "next-intl/server"
|
|
import { routing } from "./routing"
|
|
import { loadMessages } from "./loadMessages"
|
|
|
|
/**
|
|
* Per-request i18n config consumed by next-intl on every page render.
|
|
*
|
|
* Loads the entire translation tree for the active locale by walking
|
|
* `messages/<locale>/` (see loadMessages.ts). Conventions:
|
|
*
|
|
* - `common.json` / `index.json` → keys merged at root
|
|
* - `<name>.json` → namespace `<name>.*`
|
|
* - sub-directories → nested namespace
|
|
*
|
|
* Missing translations transparently fall back to English. When a
|
|
* translator hasn't finished a section yet the user sees the English
|
|
* text instead of a broken `MISSING_MESSAGE` placeholder.
|
|
*/
|
|
export default getRequestConfig(async ({ requestLocale }) => {
|
|
const requested = await requestLocale
|
|
const locale = hasLocale(routing.locales, requested)
|
|
? requested
|
|
: routing.defaultLocale
|
|
|
|
const enMessages = loadMessages("en")
|
|
const localeMessages = locale === "en" ? {} : loadMessages(locale)
|
|
|
|
return {
|
|
locale,
|
|
messages: deepMerge(enMessages, localeMessages),
|
|
}
|
|
})
|
|
|
|
/**
|
|
* Deep-merge two message trees so the locale's translations override
|
|
* the English defaults while still falling back to English for any
|
|
* key the translator hasn't filled in yet.
|
|
*/
|
|
function deepMerge(
|
|
base: Record<string, unknown>,
|
|
override: Record<string, unknown>,
|
|
): Record<string, unknown> {
|
|
const out: Record<string, unknown> = { ...base }
|
|
for (const [k, v] of Object.entries(override)) {
|
|
if (
|
|
v &&
|
|
typeof v === "object" &&
|
|
!Array.isArray(v) &&
|
|
typeof out[k] === "object" &&
|
|
out[k] !== null &&
|
|
!Array.isArray(out[k])
|
|
) {
|
|
out[k] = deepMerge(
|
|
out[k] as Record<string, unknown>,
|
|
v as Record<string, unknown>,
|
|
)
|
|
} else {
|
|
out[k] = v
|
|
}
|
|
}
|
|
return out
|
|
}
|