# gt-node: General Translation Node.js SDK: getLocale
URL: https://generaltranslation.com/en-US/docs/node/reference/functions/get-locale.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Read the active locale for the current request in General Translation gt-node. API reference for getLocale.

Returns the active locale as a BCP 47 code. Call it inside a [`withGT`](/docs/node/reference/functions/with-gt) scope to read the locale bound for the request.

## Overview [#overview]

Call `getLocale` with no arguments to get the active BCP 47 locale code.

```ts
import { getLocale } from 'gt-node';

const locale = getLocale(); // 'en-US'
```

Signature:

```ts
getLocale(): string
```

*Note: `getLocale` must be called within a [`withGT`](/docs/node/reference/functions/with-gt) callback so it knows which locale to use.*

## How it works [#how-it-works]

- **Request-scoped.** It reads the locale bound by the surrounding [`withGT`](/docs/node/reference/functions/with-gt) call.
- **Synchronous.** It returns immediately and does not need to be awaited.

## Parameters [#parameters]

`getLocale` takes no parameters.

## Returns [#returns]

**Type** `string`

The current BCP 47 locale code (for example, `'en-US'`).

## Examples [#examples]

```ts title="handler.js"
// Basic usage
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()); // 'en-US'
    next();
  });
});
```

## Sitemap

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