useLocale
Injects the Origam locale instance created by createLocale() (or the vue-i18n adapter wired in createOrigam()). Provides the current locale ref, the RTL flag, and the translation function used by all internal DS components. Throws if called outside a createOrigam context.
API
Signature
Full TypeScript signature sourced from the composable file.
useLocale exposes the DS-internal translation keys only. For application-level i18n (your own strings), keep using @nuxtjs/i18n or vue-i18n directly. The DS adapter wires into your existing i18n instance when configured via createOrigam({ locale: { adapter } }).
Consumed interfaces
API
Parameters
Input parameters accepted by this composable.
- strictrequiredfalse
API
Return values
Properties and methods exposed by the composable return object.
- current
- Reactive BCP-47 locale tag (e.g. "en", "fr", "ar"). Changing this ref switches the active DS locale.
- fallback
- Fallback locale used when a message key is not found in current.
- t
- Translation function for DS-internal message keys (e.g. "close", "pagination.next"). Uses the current locale.
- isRtl
- True when the active locale is configured as RTL in the rtl map passed to createOrigam().
- rtl
- Map of locale → RTL boolean. Editable at runtime to toggle directionality per locale.
Usage
Examples
Ready-to-paste usage snippets.
Read the active locale in a component
Switch locale at runtime
Override locale for a component subtree (provideLocale)