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
Signature TypeScript complète extraite du fichier du composable.
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 } }).
Interfaces consommées
API
Paramètres
Paramètres d'entrée acceptés par ce composable.
- strictrequisfalse
API
Valeurs de retour
Propriétés et méthodes exposées par l'objet retourné par le composable.
- 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
Exemples
Extraits de code prêts à coller.
Read the active locale in a component
Switch locale at runtime
Override locale for a component subtree (provideLocale)