useLocale@astryxdesign/core v0.5.2 · useLocale
Install with shadcn
Experimental compatibility. This installs the real Astryx package and creates a local public re-export; it does not copy component implementation source. How compatibility works.
This install URL expires with the draft preview.bashnpx shadcn@latest add https://astryx-2z5i6c2u1-fbopensource.vercel.app/r/astryx-component-use-locale.json
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.
tsimport {useLocale} from '@astryxdesign/core/i18n'
Best practices
| Guidance | Practices |
|---|---|
| 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
| Field | Type | Description |
|---|---|---|
| locale | The active InternationalizationProvider BCP 47 locale. Falls back to 'en' when no provider is present. |