[**Documentation**](../../../README)

***

[Documentation](../../../README) / [@zerotal/i18n](../README) / LocaleMiddleware

# Class: LocaleMiddleware

Defined in: [i18n/src/LocaleMiddleware.ts:13](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/i18n/src/LocaleMiddleware.ts#L13)

Resolves the request locale, exposes `ctx.locale` + `ctx.t()`, and runs the
rest of the pipeline inside `I18nContext.run()` so the `Lang` facade and the
global `t()` helper see the right locale. Configured by I18nProvider via
`LocaleMiddleware.configure()` and registered with `app.useOnce()`.

## Implements

- [`Pipe`](../../core/index/interfaces/Pipe)\<[`HttpContext`](../../core/index/classes/HttpContext)\>

## Constructors

### Constructor

> **new LocaleMiddleware**(): `LocaleMiddleware`

#### Returns

`LocaleMiddleware`

## Methods

### configure()

> `static` **configure**(`translator`, `config`): `void`

Defined in: [i18n/src/LocaleMiddleware.ts:17](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/i18n/src/LocaleMiddleware.ts#L17)

#### Parameters

##### translator

[`Translator`](Translator)

##### config

[`I18nConfigShape`](../interfaces/I18nConfigShape)

#### Returns

`void`

***

### handle()

> **handle**(`http`, `next`): `Promise`\<`void` \| `Response`\>

Defined in: [i18n/src/LocaleMiddleware.ts:22](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/i18n/src/LocaleMiddleware.ts#L22)

#### Parameters

##### http

[`HttpContext`](../../core/index/classes/HttpContext)

##### next

[`NextFn`](../../core/index/type-aliases/NextFn)

#### Returns

`Promise`\<`void` \| `Response`\>

#### Implementation of

[`Pipe`](../../core/index/interfaces/Pipe).[`handle`](../../core/index/interfaces/Pipe#handle)
