import { ID } from "../../types/index.mjs"; import { ContextTrinity } from "../createTrinity/index.mjs"; import { SingleContext, SingleOptions, SingleTicket, SingleTicketInput } from "../createSingle/index.mjs"; import { Plugin } from "../createPlugin/index.mjs"; import { TokenCollection } from "../createTokens/index.mjs"; import { LocaleAdapter, LocaleAdapterContext } from "./adapters/adapter.mjs"; import { V0LocaleAdapter } from "./adapters/v0.mjs"; import "./adapters/index.mjs"; import "../index.mjs"; //#region src/composables/useLocale/index.d.ts type LocaleRecord = TokenCollection; /** * Input type for locale tickets - what users provide to register(). */ interface LocaleTicketInput extends SingleTicketInput { messages?: LocaleRecord; } /** * Output type for locale tickets - what users receive from get(). */ type LocaleTicket = SingleTicket; interface LocaleContext = LocaleTicket> extends Omit, 'register'> { /** * Translate a message key with optional parameters. * * @param key - The message key to look up * @param params - Optional named params object, followed by positional params * @returns The translated and interpolated message * * @example * ```ts * // Simple key lookup * locale.t('hello') // Returns message for 'hello' or 'hello' if not found * * // With named parameters * locale.t('greeting', { name: 'World' }) // 'Hello {name}' → 'Hello World' * * // With positional parameters * locale.t('sum', 1, 2, 3) // 'Sum: {0} + {1} = {2}' → 'Sum: 1 + 2 = 3' * ``` */ t: (key: string, ...params: unknown[]) => string; /** * Translate a message key only if it exists, otherwise return `undefined`. * * Unlike {@link t}, `ti` ("translate if exists") never echoes the raw key on a * miss. This lets components supply their own inline English default with the * nullish-coalescing operator instead of relying on bundled fallback messages. * * @param key - The message key to look up * @param params - Optional named params object, followed by positional params * @returns The translated and interpolated message, or `undefined` if missing * * @example * ```ts * // Falls back to an inline default when the key is not translated * locale.ti('Pagination.next') ?? 'Next page' * ``` */ ti: (key: string, ...params: unknown[]) => string | undefined; n: (value: number) => string; /** Active locale adapter. */ adapter: LocaleAdapter; /** * Register a locale with optional messages. * * When `messages` is provided, flattens them to dot-notation tokens * and onboards them into the token registry before registering the * locale for selection. * * @example * ```ts * const locale = createLocale({ messages: { en }, default: 'en' }) * * // Lazy-load Dutch at runtime * const nl = await import('./locales/nl') * locale.register({ id: 'nl', messages: nl.default }) * locale.select('nl') * ``` */ register: (registration?: Partial) => E; } interface LocaleOptions extends SingleOptions { adapter?: LocaleAdapter; default?: ID; fallback?: ID; messages?: Record; } interface LocaleContextOptions extends LocaleOptions { namespace?: string; } interface LocalePluginOptions extends LocaleContextOptions { persist?: boolean; } /** * Creates a new locale instance. * * @param options The options for the locale instance. * @returns A new locale instance. * * @see https://0.vuetifyjs.com/composables/plugins/use-locale */ declare function createLocale(_options?: LocaleOptions): LocaleContext; declare function createLocaleFallback(): LocaleContext; declare const createLocaleContext: <_E extends LocaleContext> = LocaleContext>>(_options?: LocalePluginOptions | undefined) => ContextTrinity<_E>, createLocalePlugin: (_options?: (LocalePluginOptions & Pick<{ namespace?: string; persist?: boolean; devtools?: boolean; }, "devtools">) | undefined) => Plugin, useLocale: <_E extends LocaleContext> = LocaleContext>>(namespace?: string) => _E; //#endregion export { LocaleAdapter, type LocaleAdapterContext, LocaleContext, LocaleContextOptions, LocaleOptions, LocalePluginOptions, LocaleRecord, LocaleTicket, LocaleTicketInput, V0LocaleAdapter, createLocale, createLocaleContext, createLocaleFallback, createLocalePlugin, useLocale };