useLocale API
API reference for the useLocale composable.
Functions
createLocaleFallback
() => RcreateLocaleContext
(_options?: LocaleContextOptions) => ContextTrinity<R>Creates a new locale context.
Options
enroll
MaybeRefOrGetter<boolean>When true, newly registered items are automatically selected if not disabled. Useful for pre-selecting items in multi-select scenarios.
mandatory
MaybeRefOrGetter<boolean | "force">Controls mandatory selection behavior: - `false` (default): No mandatory selection enforcement - `true`: Prevents deselecting the last selected item (user must always have one selected) - `'force'`: Automatically selects the first non-disabled item on registration
adapter
LocaleAdapterdefault
IDfallback
IDmessages
Record<ID, Z>Properties
selectedId
ComputedRef<any>selectedIndex
ComputedRef<number>selectedItem
ComputedRef<E>selectedValue
ComputedRef<E["value"]>Methods
seek
(direction?: "first" | "last", from?: number, predicate?: (ticket) => boolean) => Z | undefinedSeek for a ticket based on direction and optional predicate
on
<K extends Extensible<RegistryEventName>>(event: K, cb: EventHandler<Z, K>) => voidListen for registry events
off
<K extends Extensible<RegistryEventName>>(event: K, cb: EventHandler<Z, K>) => voidStop listening for registry events
emit
<K extends Extensible<RegistryEventName>>(event: K, data: EventPayload<Z, K>) => voidEmit an event with data
batch
<R>(fn: () => R) => RExecute operations in a batch, deferring cache invalidation and event emission until complete
t
(key: string, params?: Record<string, unknown>, fallback?: string) => stringTranslate a message key with optional parameters and fallback.
n
(value: number) => string