Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
@@ -3,9 +3,10 @@ import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { createCookie } from "react-router";
|
||||
|
||||
import { loadRequiredWebConfig, resolveSessionCookiePolicy } from "@toolctrl/config";
|
||||
import { loadRequiredWebConfig, resolveSessionCookiePolicy } from "@hivegrid/config";
|
||||
import { RemixI18Next } from "remix-i18next/server";
|
||||
import { i18nConfig, i18nNamespaces } from "./i18n";
|
||||
import { effectiveLng, formalLngs, i18nConfig, i18nNamespaces } from "./i18n";
|
||||
import { resolveAnrede } from "./anrede.server";
|
||||
|
||||
import Backend from "i18next-fs-backend";
|
||||
|
||||
@@ -57,6 +58,13 @@ export const remixI18Next = new RemixI18Next({
|
||||
// Server-Side only messages.
|
||||
i18next: {
|
||||
...i18nConfig,
|
||||
// Allow the formal variants ("de-formal", "en-formal") as *translation*
|
||||
// languages so `getFixedT("<locale>-formal")` resolves the formal bundle
|
||||
// (and falls back to the base locale for un-overridden keys). Detection
|
||||
// (`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`,
|
||||
@@ -68,13 +76,20 @@ export const remixI18Next = new RemixI18Next({
|
||||
plugins: [Backend],
|
||||
});
|
||||
|
||||
export async function getTranslations(request: Request, namespace = "translations") {
|
||||
export async function getTranslations(request: Request, namespace = "translations", options?: { tenant?: { anrede?: string | null } | null }) {
|
||||
// Load every namespace so callers can resolve cross-namespace keys like
|
||||
// `t("auth:errors.invalidEmail")` while `namespace` stays the default for
|
||||
// un-prefixed keys. See #72 i18n namespace split.
|
||||
const namespaces: [string, ...string[]] = [namespace, ...i18nNamespaces.filter((ns) => ns !== namespace)];
|
||||
const t = await remixI18Next.getFixedT(request, namespaces);
|
||||
let translations: any = {};
|
||||
const locale = await remixI18Next.getLocale(request);
|
||||
// Resolve the formality axis and translate against the *effective* language.
|
||||
// With the default "du" (no cookie/param, "du"/unset tenant) `effectiveLng`
|
||||
// returns the plain locale, so `getFixedT(locale, …)` is equivalent to the
|
||||
// previous `getFixedT(request, …)` — byte-identical output. "sie" switches to
|
||||
// "<locale>-formal" and falls back to the base locale for un-overridden keys.
|
||||
const anrede = await resolveAnrede(request, options?.tenant);
|
||||
const lng = effectiveLng(locale, anrede);
|
||||
const t = await remixI18Next.getFixedT(lng, namespaces);
|
||||
let translations: any = {};
|
||||
return { t, translations, locale };
|
||||
}
|
||||
Reference in new issue
Block a user