Initial commit of Descrybe v2 without local scratch artifacts.

Drop one-shot tmp/axe scripts and agent i18n scratch so the Gitea tree is deployable.
This commit is contained in:
greeneclipse committed 2026-08-09 22:47:43 +02:00
commit 8580c996c3
1285 files changed
+325780

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
import type { MessageDict } from "./types.ts";
import { en } from "./en.ts";
type LocaleModule = Record<string, MessageDict>;
/**
* Per-locale dynamic import factories. Only `en` is statically resident
* (SSR default + missing-key fallback). Other packs load on demand.
*/
const LOCALE_LOADERS: Record<string, () => Promise<LocaleModule>> = {
en: async () => ({ en }),
es: () => import("./es.ts"),
fr: () => import("./fr.ts"),
de: () => import("./de.ts"),
it: () => import("./it.ts"),
pt: () => import("./pt.ts"),
nl: () => import("./nl.ts"),
pl: () => import("./pl.ts"),
ja: () => import("./ja.ts")
};
/**
* Sync cache of packs that have been loaded. English is always present.
* Missing keys still fall back to `en` via resolveMessage / i18n.t.
*/
export const MESSAGE_CATALOG: Record<string, MessageDict> = {
en
};
export function isRegisteredCatalogLocale(locale: string): boolean {
return Object.prototype.hasOwnProperty.call(LOCALE_LOADERS, locale);
}
export function messagesFor(locale: string): MessageDict {
return MESSAGE_CATALOG[locale] ?? {};
}
/** Load (and cache) one locale pack. Idempotent; safe on SSR and client. */
export async function loadMessages(locale: string): Promise<MessageDict> {
const cached = MESSAGE_CATALOG[locale];
if (cached) return cached;
const loader = LOCALE_LOADERS[locale];
if (!loader) return {};
const mod = await loader();
const pack = mod[locale] ?? {};
MESSAGE_CATALOG[locale] = pack;
return pack;
}
/** Load every registered locale (tests / offline coverage tools). */
export async function loadAllMessages(): Promise<Record<string, MessageDict>> {
await Promise.all(Object.keys(LOCALE_LOADERS).map((code) => loadMessages(code)));
return { ...MESSAGE_CATALOG };
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+2
View File
@@ -0,0 +1,2 @@
/** Flat message dictionary. Prefer dotted keys: "nav.dashboard". */
export type MessageDict = Record<string, string>;