useLocale
@astryxdesign/core v0.7.1 · 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 '@astryx-vue/core/locale'The returned locale is a computed string, so the template unwraps it and any watch or computed follows the provider when it switches language. Tags are normalized on the way out: zh, zh-CN, and zh-Hans read as zh-CN, and every other tag keeps its region with canonical casing, so en-gb reads as en-GB.
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. |