# General Translation Changelog: gt-node 0.3.0: 区域设置工具函数
URL: https://generaltranslation.com/zh/blog/gt-node_v0_3_0.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: 
Authors: Ernest McCarter
Published: 2026-03-09

## 概述

`gt-node` 现在会导出区域设置工具函数：[`getLocale()`](/docs/node/reference/functions/get-locale), [`getDefaultLocale()`](/docs/node/reference/functions/get-default-locale), [`getLocales()`](/docs/node/reference/functions/get-locales), and [`getLocaleProperties()`](/docs/node/reference/functions/get-locale-properties)。

这些函数此前已存在于 `gt-next` 和 `gt-react` 中。现在将它们加入 `gt-node` 后，服务端也实现了对齐，因此你无需直接访问 i18n 管理器，也能获取区域设置信息。

## 新增内容

### `getLocale()`

返回当前请求的区域设置。

```js
import { withGT, getLocale } from 'gt-node';

app.use((req, res, next) => {
  const locale = req.headers['accept-language']?.split(',')[0] || 'en-US';
  withGT(locale, () => {
    console.log(getLocale()); // 'es'
    next();
  });
});
```


### `getDefaultLocale()`

返回在 [`initializeGT`](/docs/node/reference/functions/initialize-gt) 中配置的默认区域设置。

```js
import { getDefaultLocale } from 'gt-node';

console.log(getDefaultLocale()); // 'en-US'
```

### `getLocales()`

返回支持的区域设置列表。

```js
import { getLocales } from 'gt-node';

console.log(getLocales()); // ['en-US', 'es', 'fr']
```


### `getLocaleProperties()`

返回某个区域设置的元数据，例如名称、本地名称、地区、文字系统等。

```js
import { getLocaleProperties } from 'gt-node';

const props = getLocaleProperties('ja');
console.log(props.nativeName); // '日本語'
```

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
