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
+15
-4
@@ -3,9 +3,15 @@ import path from "node:path";
|
||||
|
||||
import i18next, { type Resource, type ResourceLanguage } from "i18next";
|
||||
|
||||
import { i18nConfig, i18nNamespaces, supportedLocales } from "./i18n";
|
||||
import { formalLngs, i18nConfig, i18nNamespaces, supportedLocales } from "./i18n";
|
||||
import { serverLocalePath } from "./i18next.server";
|
||||
|
||||
// The global instance must be able to render *and* `changeLanguage` into the
|
||||
// formal variants ("de-formal", "en-formal") in addition to the base locales.
|
||||
// Their bundles are loaded best-effort (missing files are non-fatal) and fall
|
||||
// back to the base locale for un-overridden keys.
|
||||
const globalLngs = [...supportedLocales, ...formalLngs];
|
||||
|
||||
/**
|
||||
* Server-side bootstrap for the *global* i18next instance (the default export
|
||||
* of `i18next`). A large number of components resolve translations through the
|
||||
@@ -27,7 +33,7 @@ import { serverLocalePath } from "./i18next.server";
|
||||
|
||||
function loadAllResources(): Resource {
|
||||
const resources: Resource = {};
|
||||
for (const locale of supportedLocales) {
|
||||
for (const locale of globalLngs) {
|
||||
const bundle: ResourceLanguage = {};
|
||||
for (const namespace of i18nNamespaces) {
|
||||
try {
|
||||
@@ -35,7 +41,8 @@ function loadAllResources(): Resource {
|
||||
bundle[namespace] = JSON.parse(readFileSync(file, "utf8")) as ResourceLanguage[string];
|
||||
} catch {
|
||||
// A missing namespace file is non-fatal: i18next will fall back to the
|
||||
// fallback language / key for that namespace.
|
||||
// fallback language / key for that namespace. This is also the path the
|
||||
// formal variants take until their override files exist on disk.
|
||||
bundle[namespace] = {};
|
||||
}
|
||||
}
|
||||
@@ -71,8 +78,12 @@ export async function ensureServerGlobalI18n(): Promise<typeof i18next> {
|
||||
initPromise = i18next
|
||||
.init({
|
||||
...i18nConfig,
|
||||
// Accept the formal variants as valid languages so a later
|
||||
// `changeLanguage("<locale>-formal")` is honoured instead of being
|
||||
// dropped back to the detection fallback.
|
||||
supportedLngs: globalLngs,
|
||||
lng: i18nConfig.fallbackLng,
|
||||
preload: [...supportedLocales],
|
||||
preload: [...globalLngs],
|
||||
resources,
|
||||
// Resources are bundled in memory, so no backend/async loading is needed.
|
||||
initImmediate: false,
|
||||
|
||||
Reference in new issue
Block a user