@astrolicious/i18n
Version:
Yet another i18n integration for Astro with server and client utilities, type safety and translations built-in.
352 lines (349 loc) • 13.2 kB
TypeScript
import * as sitemap from 'sitemap';
import { z } from 'astro/zod';
declare const optionsSchema: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
/**
* @description Sets the default locale for your website.
* @link https://astro-i18n.netlify.app/usage/configuration/#defaultlocale-required
*/
defaultLocale: z.ZodString;
/**
* @description Sets the available locales for your website. Must include the default locale.
* @link https://astro-i18n.netlify.app/usage/configuration/#locales-required
*/
locales: z.ZodArray<z.ZodString, "many">;
/**
* @description Defines how your routes are generated:
*
* - `"prefixWithoutDefault"` will not add a prefix for your default locale *
* - `"prefix"` will add a prefix for your default locale.
*
* @default `"prefixWithoutDefault"`
* @link https://astro-i18n.netlify.app/usage/configuration/#strategy
*/
strategy: z.ZodDefault<z.ZodOptional<z.ZodEnum<["prefix", "prefixExceptDefault"]>>>;
/**
* @description Allows you to define translated paths for your locales.
* @link https://astro-i18n.netlify.app/usage/configuration/#pages
*/
pages: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodString>>>>>, {
[k: string]: Record<string, string | undefined>;
}, Record<string, Record<string, string | undefined>> | undefined>;
/**
* @description A path relative to the root where locales files are located for translations features.
* @default `"./src/locales"`
* @link https://astro-i18n.netlify.app/usage/configuration/#localesdir
*/
localesDir: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodString>>, string, string | undefined>;
/**
* @description Sets the default namespace for locales. Since `astro-i18n` uses `i18next` under the hood,
* it allows to split translations data in multiple json files under `src/locales/[locale]/`. If you're not
* using a file called `common.json`, you need to update this property to have proper types completions
* when using `t`.
*
* @default `"common"`
* @link https://astro-i18n.netlify.app/usage/configuration/#defaultnamespace
*/
defaultNamespace: z.ZodDefault<z.ZodOptional<z.ZodString>>;
/**
* @description Client usage is disabled by default because it sends some JavaScript to the browser. Enabling
* any of the following features requires importing the `<I18nClient/>` component.
*
* - `t`: `data`, `translations`
* - `getLocale`: `data`
* - `getLocales`: `data`
* - `getDefaultLocale`: `data`
* - `getHtmlAttrs`: `data`
* - `setDynamicParams`: N/A, server only
* - `getLocalePath`: `data`, `paths`
* - `switchLocalePath`: `data`, `paths`
* - `getSwitcherData`: `data`, `paths`
* - `getLocalePlaceholder`: N/A, `getStaticPaths` only
* - `getLocalesPlaceholder`: N/A, `getStaticPaths` only
* - `getDefaultLocalePlaceholder`: N/A, `getStaticPaths` only
*
* @default `false`
* @link https://astro-i18n.netlify.app/usage/configuration/#client
*/
client: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodLiteral<false>, z.ZodObject<{
/**
* @description Allows using `t` on the client.
* @default `false`
* @link https://astro-i18n.netlify.app/usage/configuration/#client
*/
translations: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
/**
* @description Allows using `t`, `getLocale`, `getLocales`, `getHtmlAttrs`, `getLocalePath`,
* `switchLocalePath` and `getSwitcherData` on the client.
*
* @default `false`
* @link https://astro-i18n.netlify.app/usage/configuration/#client
*/
data: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
/**
* @description Allows using `getLocalePath`, `switchLocalePath` and `getSwitcherData` on the client.
* @default `false`
* @link https://astro-i18n.netlify.app/usage/configuration/#client
*/
paths: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
}, "strip", z.ZodTypeAny, {
data: boolean;
translations: boolean;
paths: boolean;
}, {
data?: boolean | undefined;
translations?: boolean | undefined;
paths?: boolean | undefined;
}>]>>>, {
data: boolean;
translations: boolean;
paths: boolean;
}, false | {
data?: boolean | undefined;
translations?: boolean | undefined;
paths?: boolean | undefined;
} | undefined>;
/**
* @description When using `strategy: "prefix"`, you may want to redirect your users from the root to a specific
* page (likely the default locale root). This option allows you to do so.
* @link https://astro-i18n.netlify.app/usage/configuration/#rootredirect
*/
rootRedirect: z.ZodOptional<z.ZodObject<{
status: z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodLiteral<300>, z.ZodLiteral<301>]>, z.ZodLiteral<302>]>, z.ZodLiteral<303>]>, z.ZodLiteral<304>]>, z.ZodLiteral<307>]>, z.ZodLiteral<308>]>;
destination: z.ZodString;
}, "strip", z.ZodTypeAny, {
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
destination: string;
}, {
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
destination: string;
}>>;
/**
* @description Allows to generate a sitemap that adapts to your i18n content
* @link https://astro-i18n.netlify.app/usage/configuration/#sitemap
*/
sitemap: z.ZodEffects<z.ZodDefault<z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
customPages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
entryLimit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
changefreq: z.ZodOptional<z.ZodNativeEnum<typeof sitemap.EnumChangefreq>>;
lastmod: z.ZodOptional<z.ZodDate>;
priority: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
entryLimit: number;
customPages?: string[] | undefined;
changefreq?: sitemap.EnumChangefreq | undefined;
lastmod?: Date | undefined;
priority?: number | undefined;
}, {
customPages?: string[] | undefined;
entryLimit?: number | undefined;
changefreq?: sitemap.EnumChangefreq | undefined;
lastmod?: Date | undefined;
priority?: number | undefined;
}>]>>>, {
entryLimit: number;
customPages?: string[] | undefined;
changefreq?: sitemap.EnumChangefreq | undefined;
lastmod?: Date | undefined;
priority?: number | undefined;
} | undefined, boolean | {
customPages?: string[] | undefined;
entryLimit?: number | undefined;
changefreq?: sitemap.EnumChangefreq | undefined;
lastmod?: Date | undefined;
priority?: number | undefined;
} | undefined>;
}, "strip", z.ZodTypeAny, {
defaultLocale: string;
locales: string[];
strategy: "prefix" | "prefixExceptDefault";
pages: {
[k: string]: Record<string, string | undefined>;
};
localesDir: string;
defaultNamespace: string;
client: {
data: boolean;
translations: boolean;
paths: boolean;
};
rootRedirect?: {
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
destination: string;
} | undefined;
sitemap?: {
entryLimit: number;
customPages?: string[] | undefined;
changefreq?: sitemap.EnumChangefreq | undefined;
lastmod?: Date | undefined;
priority?: number | undefined;
} | undefined;
}, {
defaultLocale: string;
locales: string[];
strategy?: "prefix" | "prefixExceptDefault" | undefined;
pages?: Record<string, Record<string, string | undefined>> | undefined;
localesDir?: string | undefined;
defaultNamespace?: string | undefined;
client?: false | {
data?: boolean | undefined;
translations?: boolean | undefined;
paths?: boolean | undefined;
} | undefined;
rootRedirect?: {
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
destination: string;
} | undefined;
sitemap?: boolean | {
customPages?: string[] | undefined;
entryLimit?: number | undefined;
changefreq?: sitemap.EnumChangefreq | undefined;
lastmod?: Date | undefined;
priority?: number | undefined;
} | undefined;
}>, {
defaultLocale: string;
locales: string[];
strategy: "prefix" | "prefixExceptDefault";
pages: {
[k: string]: Record<string, string | undefined>;
};
localesDir: string;
defaultNamespace: string;
client: {
data: boolean;
translations: boolean;
paths: boolean;
};
rootRedirect?: {
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
destination: string;
} | undefined;
sitemap?: {
entryLimit: number;
customPages?: string[] | undefined;
changefreq?: sitemap.EnumChangefreq | undefined;
lastmod?: Date | undefined;
priority?: number | undefined;
} | undefined;
}, {
defaultLocale: string;
locales: string[];
strategy?: "prefix" | "prefixExceptDefault" | undefined;
pages?: Record<string, Record<string, string | undefined>> | undefined;
localesDir?: string | undefined;
defaultNamespace?: string | undefined;
client?: false | {
data?: boolean | undefined;
translations?: boolean | undefined;
paths?: boolean | undefined;
} | undefined;
rootRedirect?: {
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
destination: string;
} | undefined;
sitemap?: boolean | {
customPages?: string[] | undefined;
entryLimit?: number | undefined;
changefreq?: sitemap.EnumChangefreq | undefined;
lastmod?: Date | undefined;
priority?: number | undefined;
} | undefined;
}>, {
defaultLocale: string;
locales: string[];
strategy: "prefix" | "prefixExceptDefault";
pages: {
[k: string]: Record<string, string | undefined>;
};
localesDir: string;
defaultNamespace: string;
client: {
data: boolean;
translations: boolean;
paths: boolean;
};
rootRedirect?: {
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
destination: string;
} | undefined;
sitemap?: {
entryLimit: number;
customPages?: string[] | undefined;
changefreq?: sitemap.EnumChangefreq | undefined;
lastmod?: Date | undefined;
priority?: number | undefined;
} | undefined;
}, {
defaultLocale: string;
locales: string[];
strategy?: "prefix" | "prefixExceptDefault" | undefined;
pages?: Record<string, Record<string, string | undefined>> | undefined;
localesDir?: string | undefined;
defaultNamespace?: string | undefined;
client?: false | {
data?: boolean | undefined;
translations?: boolean | undefined;
paths?: boolean | undefined;
} | undefined;
rootRedirect?: {
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
destination: string;
} | undefined;
sitemap?: boolean | {
customPages?: string[] | undefined;
entryLimit?: number | undefined;
changefreq?: sitemap.EnumChangefreq | undefined;
lastmod?: Date | undefined;
priority?: number | undefined;
} | undefined;
}>, {
defaultLocale: string;
locales: string[];
strategy: "prefix" | "prefixExceptDefault";
pages: {
[k: string]: Record<string, string | undefined>;
};
localesDir: string;
defaultNamespace: string;
client: {
data: boolean;
translations: boolean;
paths: boolean;
};
rootRedirect?: {
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
destination: string;
} | undefined;
sitemap?: {
entryLimit: number;
customPages?: string[] | undefined;
changefreq?: sitemap.EnumChangefreq | undefined;
lastmod?: Date | undefined;
priority?: number | undefined;
} | undefined;
}, {
defaultLocale: string;
locales: string[];
strategy?: "prefix" | "prefixExceptDefault" | undefined;
pages?: Record<string, Record<string, string | undefined>> | undefined;
localesDir?: string | undefined;
defaultNamespace?: string | undefined;
client?: false | {
data?: boolean | undefined;
translations?: boolean | undefined;
paths?: boolean | undefined;
} | undefined;
rootRedirect?: {
status: 300 | 301 | 302 | 303 | 304 | 307 | 308;
destination: string;
} | undefined;
sitemap?: boolean | {
customPages?: string[] | undefined;
entryLimit?: number | undefined;
changefreq?: sitemap.EnumChangefreq | undefined;
lastmod?: Date | undefined;
priority?: number | undefined;
} | undefined;
}>;
type Options = z.infer<typeof optionsSchema>;
export { type Options, optionsSchema };