Rename i18nInitializer by i18nBuilder

This commit is contained in:
Joseph Garrone 2024-09-21 23:08:45 +02:00
parent 8623037224
commit b3c4208e44
9 changed files with 34 additions and 34 deletions

View File

@ -1,3 +1,3 @@
export type { ExtendKcContext } from "keycloakify/account/KcContext"; export type { ExtendKcContext } from "keycloakify/account/KcContext";
export type { ClassKey } from "keycloakify/account/TemplateProps"; export type { ClassKey } from "keycloakify/account/TemplateProps";
export { i18nInitializer, type MessageKey_defaultSet } from "keycloakify/account/i18n"; export { i18nBuilder, type MessageKey_defaultSet } from "keycloakify/account/i18n";

View File

@ -4,7 +4,7 @@ import type {
} from "../messages_defaultSet/types"; } from "../messages_defaultSet/types";
import { type ReturnTypeOfCreateGetI18n, createGetI18n } from "./getI18n"; import { type ReturnTypeOfCreateGetI18n, createGetI18n } from "./getI18n";
export type I18nInitializer< export type i18nBuilder<
ThemeName extends string = never, ThemeName extends string = never,
MessageKey_themeDefined extends string = never, MessageKey_themeDefined extends string = never,
LanguageTag_notInDefaultSet extends string = never, LanguageTag_notInDefaultSet extends string = never,
@ -14,7 +14,7 @@ export type I18nInitializer<
| "withCustomTranslations" = never | "withCustomTranslations" = never
> = Omit< > = Omit<
{ {
withThemeName: <ThemeName extends string>() => I18nInitializer< withThemeName: <ThemeName extends string>() => i18nBuilder<
ThemeName, ThemeName,
MessageKey_themeDefined, MessageKey_themeDefined,
LanguageTag_notInDefaultSet, LanguageTag_notInDefaultSet,
@ -29,7 +29,7 @@ export type I18nInitializer<
default: Record<MessageKey_defaultSet, string>; default: Record<MessageKey_defaultSet, string>;
}>; }>;
}; };
}) => I18nInitializer< }) => i18nBuilder<
ThemeName, ThemeName,
MessageKey_themeDefined, MessageKey_themeDefined,
LanguageTag_notInDefaultSet, LanguageTag_notInDefaultSet,
@ -44,7 +44,7 @@ export type I18nInitializer<
string | Record<ThemeName, string> string | Record<ThemeName, string>
>; >;
}> }>
) => I18nInitializer< ) => i18nBuilder<
ThemeName, ThemeName,
MessageKey_themeDefined, MessageKey_themeDefined,
LanguageTag_notInDefaultSet, LanguageTag_notInDefaultSet,
@ -58,7 +58,7 @@ export type I18nInitializer<
ExcludedMethod ExcludedMethod
>; >;
function createI18nInitializer< function createi18nBuilder<
ThemeName extends string = never, ThemeName extends string = never,
MessageKey_themeDefined extends string = never, MessageKey_themeDefined extends string = never,
LanguageTag_notInDefaultSet extends string = never LanguageTag_notInDefaultSet extends string = never
@ -77,26 +77,26 @@ function createI18nInitializer<
string | Record<ThemeName, string> string | Record<ThemeName, string>
>; >;
}>; }>;
}): I18nInitializer<ThemeName, MessageKey_themeDefined, LanguageTag_notInDefaultSet> { }): i18nBuilder<ThemeName, MessageKey_themeDefined, LanguageTag_notInDefaultSet> {
const i18nInitializer: I18nInitializer< const i18nBuilder: i18nBuilder<
ThemeName, ThemeName,
MessageKey_themeDefined, MessageKey_themeDefined,
LanguageTag_notInDefaultSet LanguageTag_notInDefaultSet
> = { > = {
withThemeName: () => withThemeName: () =>
createI18nInitializer({ createi18nBuilder({
extraLanguageTranslations: params.extraLanguageTranslations, extraLanguageTranslations: params.extraLanguageTranslations,
messagesByLanguageTag_themeDefined: messagesByLanguageTag_themeDefined:
params.messagesByLanguageTag_themeDefined as any params.messagesByLanguageTag_themeDefined as any
}), }),
withExtraLanguages: extraLanguageTranslations => withExtraLanguages: extraLanguageTranslations =>
createI18nInitializer({ createi18nBuilder({
extraLanguageTranslations, extraLanguageTranslations,
messagesByLanguageTag_themeDefined: messagesByLanguageTag_themeDefined:
params.messagesByLanguageTag_themeDefined as any params.messagesByLanguageTag_themeDefined as any
}), }),
withCustomTranslations: messagesByLanguageTag_themeDefined => withCustomTranslations: messagesByLanguageTag_themeDefined =>
createI18nInitializer({ createi18nBuilder({
extraLanguageTranslations: params.extraLanguageTranslations, extraLanguageTranslations: params.extraLanguageTranslations,
messagesByLanguageTag_themeDefined messagesByLanguageTag_themeDefined
}), }),
@ -108,10 +108,10 @@ function createI18nInitializer<
}) })
}; };
return i18nInitializer; return i18nBuilder;
} }
export const i18nInitializer = createI18nInitializer({ export const i18nBuilder = createi18nBuilder({
extraLanguageTranslations: {}, extraLanguageTranslations: {},
messagesByLanguageTag_themeDefined: {} messagesByLanguageTag_themeDefined: {}
}); });

View File

@ -1,3 +1,3 @@
export type { KcContextLike } from "./getI18n"; export type { KcContextLike } from "./getI18n";
export { i18nInitializer } from "./i18nInitializer"; export { i18nBuilder } from "./i18nBuilder";
export type { MessageKey as MessageKey_defaultSet } from "../messages_defaultSet/types"; export type { MessageKey as MessageKey_defaultSet } from "../messages_defaultSet/types";

View File

@ -4,7 +4,7 @@ import type {
} from "../messages_defaultSet/types"; } from "../messages_defaultSet/types";
import { type ReturnTypeOfCreateUseI18n, createUseI18n } from "../withJsx/useI18n"; import { type ReturnTypeOfCreateUseI18n, createUseI18n } from "../withJsx/useI18n";
export type I18nInitializer< export type i18nBuilder<
ThemeName extends string = never, ThemeName extends string = never,
MessageKey_themeDefined extends string = never, MessageKey_themeDefined extends string = never,
LanguageTag_notInDefaultSet extends string = never, LanguageTag_notInDefaultSet extends string = never,
@ -14,7 +14,7 @@ export type I18nInitializer<
| "withCustomTranslations" = never | "withCustomTranslations" = never
> = Omit< > = Omit<
{ {
withThemeName: <ThemeName extends string>() => I18nInitializer< withThemeName: <ThemeName extends string>() => i18nBuilder<
ThemeName, ThemeName,
MessageKey_themeDefined, MessageKey_themeDefined,
LanguageTag_notInDefaultSet, LanguageTag_notInDefaultSet,
@ -29,7 +29,7 @@ export type I18nInitializer<
default: Record<MessageKey_defaultSet, string>; default: Record<MessageKey_defaultSet, string>;
}>; }>;
}; };
}) => I18nInitializer< }) => i18nBuilder<
ThemeName, ThemeName,
MessageKey_themeDefined, MessageKey_themeDefined,
LanguageTag_notInDefaultSet, LanguageTag_notInDefaultSet,
@ -44,7 +44,7 @@ export type I18nInitializer<
string | Record<ThemeName, string> string | Record<ThemeName, string>
>; >;
}> }>
) => I18nInitializer< ) => i18nBuilder<
ThemeName, ThemeName,
MessageKey_themeDefined, MessageKey_themeDefined,
LanguageTag_notInDefaultSet, LanguageTag_notInDefaultSet,
@ -58,7 +58,7 @@ export type I18nInitializer<
ExcludedMethod ExcludedMethod
>; >;
function createI18nInitializer< function createi18nBuilder<
ThemeName extends string = never, ThemeName extends string = never,
MessageKey_themeDefined extends string = never, MessageKey_themeDefined extends string = never,
LanguageTag_notInDefaultSet extends string = never LanguageTag_notInDefaultSet extends string = never
@ -77,26 +77,26 @@ function createI18nInitializer<
string | Record<ThemeName, string> string | Record<ThemeName, string>
>; >;
}>; }>;
}): I18nInitializer<ThemeName, MessageKey_themeDefined, LanguageTag_notInDefaultSet> { }): i18nBuilder<ThemeName, MessageKey_themeDefined, LanguageTag_notInDefaultSet> {
const i18nInitializer: I18nInitializer< const i18nBuilder: i18nBuilder<
ThemeName, ThemeName,
MessageKey_themeDefined, MessageKey_themeDefined,
LanguageTag_notInDefaultSet LanguageTag_notInDefaultSet
> = { > = {
withThemeName: () => withThemeName: () =>
createI18nInitializer({ createi18nBuilder({
extraLanguageTranslations: params.extraLanguageTranslations, extraLanguageTranslations: params.extraLanguageTranslations,
messagesByLanguageTag_themeDefined: messagesByLanguageTag_themeDefined:
params.messagesByLanguageTag_themeDefined as any params.messagesByLanguageTag_themeDefined as any
}), }),
withExtraLanguages: extraLanguageTranslations => withExtraLanguages: extraLanguageTranslations =>
createI18nInitializer({ createi18nBuilder({
extraLanguageTranslations, extraLanguageTranslations,
messagesByLanguageTag_themeDefined: messagesByLanguageTag_themeDefined:
params.messagesByLanguageTag_themeDefined as any params.messagesByLanguageTag_themeDefined as any
}), }),
withCustomTranslations: messagesByLanguageTag_themeDefined => withCustomTranslations: messagesByLanguageTag_themeDefined =>
createI18nInitializer({ createi18nBuilder({
extraLanguageTranslations: params.extraLanguageTranslations, extraLanguageTranslations: params.extraLanguageTranslations,
messagesByLanguageTag_themeDefined messagesByLanguageTag_themeDefined
}), }),
@ -108,10 +108,10 @@ function createI18nInitializer<
}) })
}; };
return i18nInitializer; return i18nBuilder;
} }
export const i18nInitializer = createI18nInitializer({ export const i18nBuilder = createi18nBuilder({
extraLanguageTranslations: {}, extraLanguageTranslations: {},
messagesByLanguageTag_themeDefined: {} messagesByLanguageTag_themeDefined: {}
}); });

View File

@ -1,3 +1,3 @@
export { i18nInitializer } from "./i18nInitializer"; export { i18nBuilder } from "./i18nBuilder";
export type { KcContextLike } from "./useI18n"; export type { KcContextLike } from "./useI18n";
export type { MessageKey as MessageKey_defaultSet } from "../messages_defaultSet/types"; export type { MessageKey as MessageKey_defaultSet } from "../messages_defaultSet/types";

View File

@ -1,3 +1,3 @@
export type { ExtendKcContext, Attribute } from "keycloakify/login/KcContext"; export type { ExtendKcContext, Attribute } from "keycloakify/login/KcContext";
export type { ClassKey } from "keycloakify/login/TemplateProps"; export type { ClassKey } from "keycloakify/login/TemplateProps";
export { i18nInitializer, type MessageKey_defaultSet } from "keycloakify/login/i18n"; export { i18nBuilder, type MessageKey_defaultSet } from "keycloakify/login/i18n";

View File

@ -1,7 +1,7 @@
import { i18nInitializer } from "../../dist/account"; import { i18nBuilder } from "../../dist/account";
import type { ThemeName } from "../kc.gen"; import type { ThemeName } from "../kc.gen";
export const { useI18n, ofTypeI18n } = i18nInitializer export const { useI18n, ofTypeI18n } = i18nBuilder
.withThemeName<ThemeName>() .withThemeName<ThemeName>()
.withCustomTranslations({}) .withCustomTranslations({})
.create(); .create();

View File

@ -1,7 +1,7 @@
import { i18nInitializer } from "../../dist/login"; import { i18nBuilder } from "../../dist/login";
import type { ThemeName } from "../kc.gen"; import type { ThemeName } from "../kc.gen";
export const { useI18n, ofTypeI18n } = i18nInitializer export const { useI18n, ofTypeI18n } = i18nBuilder
.withThemeName<ThemeName>() .withThemeName<ThemeName>()
.withCustomTranslations({}) .withCustomTranslations({})
.create(); .create();

View File

@ -1,8 +1,8 @@
import { i18nInitializer } from "keycloakify/login/i18n"; import { i18nBuilder } from "keycloakify/login/i18n";
import { assert, type Equals } from "tsafe/assert"; import { assert, type Equals } from "tsafe/assert";
import { Reflect } from "tsafe/Reflect"; import { Reflect } from "tsafe/Reflect";
const { useI18n, ofTypeI18n } = i18nInitializer const { useI18n, ofTypeI18n } = i18nBuilder
.withThemeName<"my-theme-1" | "my-theme-2">() .withThemeName<"my-theme-1" | "my-theme-2">()
.withExtraLanguages({ .withExtraLanguages({
he: { he: {