import type { Resolver } from "@/lib/resolver.js";
import type { FailedTask } from "@/lib/task.svelte.js";
import type { Schema } from "@/core/index.js";
export interface Labels {
"array-schema-missing-items": {};
"multi-schema-option-label-with-title": { title: string; index: number };
"multi-schema-option-label": { index: number };
"remove-object-property": {};
"add-object-property": {};
"move-array-item-up": {};
"move-array-item-down": {};
"validation-process-error": { error: FailedTask<unknown> };
"component-not-found": { type: string };
"key-input-title": { name: string };
"additional-property": {};
"unknown-field-error": { schema: Schema };
export type Label = keyof Labels;
export type Translator<Params> = string | ((params: Params) => string);
export type TranslatorDefinitions<R = Labels> = {
[K in keyof R]: Translator<R[K]>;
export type Translation = Resolver<
Partial<TranslatorDefinitions<Labels>>
export type Translate = <L extends Label>(
export function createTranslate<Ls>(
translation: Resolver<Partial<Ls>, Partial<TranslatorDefinitions<Ls>>>
return <L extends keyof Ls & string>(label: L, params: Ls[L]) => {
const translator: Translator<Ls[L]> | undefined = translation(
if (translator === undefined) {
return `Label "${label}" is not translated`;
return typeof translator === "string" ? translator : translator(params);