Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -1,47 +1,39 @@
import { existsSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { createCookie } from "react-router";
import { loadRequiredWebConfig, resolveSessionCookiePolicy } from "@hivegrid/config";
import { RemixI18Next } from "remix-i18next/server";
import { effectiveLng, formalLngs, i18nConfig, i18nNamespaces } from "./i18n";
import { catalogReadyLocales, defaultLocale, effectiveLng, i18nConfig, i18nNamespaces } from "./i18n";
import { resolveAnrede } from "./anrede.server";
import Backend from "i18next-fs-backend";
import { getServerI18nResourcesSnapshot, resolveServerLocalePath, serverLocalePath } from "./i18next-resources.server";
const webConfig = loadRequiredWebConfig();
type ResolveServerLocalePathOptions = {
moduleUrl?: string;
cwd?: string;
exists?: (candidate: string) => boolean;
};
export { resolveServerLocalePath, serverLocalePath };
export function resolveServerLocalePath({ moduleUrl = import.meta.url, cwd = process.cwd(), exists = existsSync }: ResolveServerLocalePathOptions = {}) {
// `path.resolve(path.dirname(fileURLToPath(url)), "../../...")` instead
// of `new URL("...", moduleUrl)` because vitest 3 resolves relative
// URL constructors through the Vite dev server (returning http://...);
// we need a file path here.
const moduleDir = path.dirname(fileURLToPath(moduleUrl));
const candidates = [
path.resolve(moduleDir, "../../public/locales"),
path.resolve(cwd, "apps/web/public/locales"),
path.resolve(cwd, "public/locales"),
];
const isPortalRuntime = webConfig.runtimeSurface === "portal";
export const enabledLocales = webConfig.i18n.enabledLocales;
return candidates.find((candidate) => exists(candidate)) ?? candidates[0];
}
export const serverLocalePath = resolveServerLocalePath();
export const i18nCookie = createCookie("_i18n", {
...resolveSessionCookiePolicy({
nodeEnv: webConfig.nodeEnv,
routing: webConfig.routing,
maxAge: 60 * 60 * 24 * 30,
}),
secrets: webConfig.sessionSecret ? [webConfig.sessionSecret] : [],
export const i18nCookie = createCookie(isPortalRuntime ? "__Host-hivegrid_portal_locale" : "_i18n", {
...(isPortalRuntime
? {
httpOnly: true,
path: "/",
sameSite: "lax" as const,
secure: true,
maxAge: 60 * 60 * 24 * 30,
}
: resolveSessionCookiePolicy({
nodeEnv: webConfig.nodeEnv,
routing: webConfig.routing,
maxAge: 60 * 60 * 24 * 30,
})),
secrets: isPortalRuntime
? webConfig.portalSessionSecret
? [webConfig.portalSessionSecret]
: []
: webConfig.sessionSecret
? [webConfig.sessionSecret]
: [],
});
export const remixI18Next = new RemixI18Next({
@@ -49,9 +41,9 @@ export const remixI18Next = new RemixI18Next({
// The cookie used to store user's language preference.
cookie: i18nCookie,
// The supported languages.
supportedLanguages: i18nConfig.supportedLngs,
supportedLanguages: [...enabledLocales],
// The fallback language.
fallbackLanguage: i18nConfig.fallbackLng,
fallbackLanguage: defaultLocale,
},
// The i18next configuration used when translating
@@ -64,16 +56,13 @@ export const remixI18Next = new RemixI18Next({
// (`detection.supportedLanguages` above) intentionally stays base-only so
// `getLocale()` — which drives `<html lang>` — never returns a non-BCP47
// "-formal" code.
supportedLngs: [...i18nConfig.supportedLngs, ...formalLngs],
backend: {
localePath: serverLocalePath,
loadPath: `${serverLocalePath}/{{lng}}/{{ns}}.json`,
},
supportedLngs: [...i18nConfig.supportedLngs, ...catalogReadyLocales.map((locale) => `${locale}-formal`)],
resources: getServerI18nResourcesSnapshot(),
},
// The plugins you want RemixI18next to use for `i18n.getFixedT` inside loaders and actions.
// E.g. The Backend plugin for loading translations from the file system.
plugins: [Backend],
plugins: [],
});
export async function getTranslations(request: Request, namespace = "translations", options?: { tenant?: { anrede?: string | null } | null }) {