useLocale API
API reference for the useLocale composable.
Related
Explore these related pages for additional context and usage patterns.
| Page | Category |
|---|---|
| useLocale | Plugins |
| Locale | Providers |
| Accessibility | Features |
Functions
createLocale
(_options?: LocaleOptions<TokenCollection>) => LocaleContext<LocaleTicketInput, LocaleTicket<LocaleTicketInput>>Creates a new locale instance.
createLocaleFallback
() => LocaleContext<LocaleTicketInput, LocaleTicket<LocaleTicketInput>>createLocaleContext
<_E>(_options?: LocalePluginOptions | undefined) => ContextTrinity<_E>createLocalePlugin
(_options?: LocalePluginOptions | undefined) => PluginuseLocale
<_E>(namespace?: string) => _EOptions
disabled
MaybeRefOrGetter<boolean> | undefinedDisabled state for the entire model instance
Default: false
multiple
MaybeRefOrGetter<boolean> | undefinedAllow multiple tickets to be selected simultaneously
Default: false
mandatory
MaybeRefOrGetter<boolean | "force"> | undefinedControls mandatory selection behavior: - `false` (default): No mandatory selection enforcement - `true`: Prevents deselecting the last selected item - `'force'`: Automatically selects the first non-disabled item on registration
adapter
LocaleAdapter | undefineddefault
ID | undefinedfallback
ID | undefinedmessages
Record<ID, Z> | undefinedProperties
selectedValues
ComputedRef<Set<E["value"] extends Ref<infer U, infer U> ? U : E["value"]>>Computed Set of selected ticket values
selectedId
Readonly<Ref<ID | undefined, ID | undefined>>selectedIndex
Readonly<Ref<number, number>>selectedItem
Readonly<Ref<E | undefined, E | undefined>>selectedValue
Readonly<Ref<E["value"] | undefined, E["value"] | undefined>>Methods
seek
(direction?: "first" | "last", from?: number, predicate?: (ticket) => boolean) => E | undefinedSeek for a ticket based on direction and optional predicate
on
<K extends Extensible<RegistryEventName>>(event: K, cb: RegistryEventCallback<E, K>) => voidListen for registry events
off
<K extends Extensible<RegistryEventName>>(event: K, cb: RegistryEventCallback<E, K>) => voidStop listening for registry events
emit
<K extends Extensible<RegistryEventName>>(event: K, data: EventPayload<E, K>) => voidEmit an event with data
offboard
(ids: ID[]) => Partial<Z>[]Offboard multiple tickets at once, returning the input shapes that were removed.
batch
<R>(fn: () => R) => RExecute operations in a batch, deferring cache invalidation and event emission until complete
ti
(key: string, ...params: unknown[]) => string | undefinedTranslate 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.
n
(value: number) => stringregister
(registration?: Partial<Z>) => ERegister 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.