Initial commit
This commit is contained in:
commit
3165625fb7
29 changed files with 7080 additions and 0 deletions
30
packages/i18n/tests/fixtures.ts
Normal file
30
packages/i18n/tests/fixtures.ts
Normal 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");
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue