# useLocale

## 使用方法

读当前生效的 Astryx 语言标签。把它交给需要显式语言的纯格式化函数或同系列的包，别从 `navigator.language` 或者写死的字面量里另取一份。

```ts
import { useLocale } from '@astryx-vue/core/locale'
```

返回的 `locale` 是 computed 字符串，模板里会自动取值，`watch` 和 `computed` 也会跟着 provider 换语言而重算。标签在出口统一收过一次：`zh`、`zh-CN`、`zh-Hans` 都读作 `zh-CN`，其余标签保留地区、只规范大小写，例如 `en-gb` 读作 `en-GB`。

## 建议

| 指引 | 实践 |
| --- | --- |
| 推荐 | 把返回的语言标签交给纯 Astryx 函数，或交给需要显式语言的包。 |
| 避免 | 把 `navigator.language` 或写死的展示语言当兜底。语言只认 `InternationalizationProvider` 这一处来源。 |

## 返回值

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| `locale` | `ComputedRef<string>` | 最近的 `InternationalizationProvider` 的 BCP 47 语言标签。没有 provider 时是 `'en'`。 |
