UNPKG

astro-loader-i18n

Version:

An Astro content loader for i18n files and folder structures.

15 lines (14 loc) 1.15 kB
import { z } from 'astro/zod'; /** * Creates a schema for localized content, supporting multiple locales. * * @template T - The Zod schema type for the content. * @template Locales - A tuple of locale strings. * @param schema - The base schema for the content. * @param locales - An array of locale strings to define the localization keys. * @param partial - Whether the schema should allow partial localization (optional). * @returns A Zod schema that validates either the localized object or the base schema. */ export declare const localized: <T extends z.ZodTypeAny, Locales extends readonly string[]>(schema: T, locales: Locales, partial?: boolean) => z.ZodUnion<[z.ZodObject<(Record<Locales[number], T> extends infer T_2 ? { -readonly [P in keyof T_2]: T_2[P]; } : never) extends infer T_1 extends Readonly<{ [k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>; }> ? { -readonly [k in keyof T_1]: z.ZodOptional<T_1[k]>; } : never, z.core.$strip>, T]> | z.ZodUnion<[z.ZodObject<Record<Locales[number], T> extends infer T_3 ? { -readonly [P in keyof T_3]: T_3[P]; } : never, z.core.$strip>, T]>;