useLocale@astryxdesign/core v0.5.2 · useLocale

Usage

Reads the authoritative Astryx locale. Use it to thread the provider locale into pure formatting helpers and sibling-package APIs; do not derive a second locale from navigator.language or a hardcoded literal.

ts
import {useLocale} from '@astryxdesign/core/i18n'

Best practices

GuidancePractices
Do

Pass the returned locale to pure Astryx helpers or package APIs that require an explicit locale.

Don't

Use navigator.language or a hardcoded display locale as a fallback; InternationalizationProvider is the locale source.

Returns

FieldTypeDescription
locale

The active InternationalizationProvider BCP 47 locale. Falls back to 'en' when no provider is present.

Use with shadcn

Already using the shadcn registry workflow? Install the real Astryx package and a local public re-export. Component implementation source stays in Astryx. How compatibility works.

This install URL expires with the draft preview.
bash
npx shadcn@latest add https://astryx-4p843mspp-fbopensource.vercel.app/r/hooks/use-locale.json