Initial commit

This commit is contained in:
M. George Hansen 2025-08-15 14:00:52 +12:00
commit 3165625fb7
Signed by: mgeorgehansen
SSH key fingerprint: SHA256:JlIGiQLPyQ2RHTH3a2oVlb20Xkh9Glr8DUF4YTXHJxM
29 changed files with 7080 additions and 0 deletions

View file

@ -0,0 +1,30 @@
import I18n, { type I18nOptions } from "@websnacksjs/i18n";
export type Fixtures = {
base: {
common: typeof import("./fixtures/base/messages/en/common.json");
drama: typeof import("./fixtures/base/messages/en/drama.json");
};
};
export const withFixture = <F extends keyof Fixtures>(
fixture: F,
overrides: Partial<I18nOptions<Fixtures[F]>> = {},
): I18n<Fixtures[F]> => {
switch (fixture) {
case "base": {
return new I18n<Fixtures["base"]>({
supportedLocales: ["en", "fr", "fr-Arab"],
namespaces: ["drama"],
messagesUrlTemplate: new URL(
"./fixtures/base/messages/:locale/:namespace.json",
import.meta.url,
),
...(overrides as Partial<I18nOptions<Fixtures["base"]>>),
});
}
default: {
throw new Error("unreachable");
}
}
};