# express-tongue

> Localization library for Express. It works with every template engine and exposes a json endpoint to consume on client side.

Latest version **2.0.1** (published 2026-11-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install express-tongue
pnpm add express-tongue
yarn add express-tongue
bun add express-tongue
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 2.0.1 |
| Published | 2026-11-24 |
| First published | 2016-03-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 20.19.0 |
| Dependencies | 1 |
| Unpacked size | 26.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Carlos Luis Castro Márquez |
| Maintainers | clcastro87 |
| Keywords | express, localization, i18n, language, tongue |

## Links

- npm: https://www.npmjs.com/package/express-tongue
- Repository: https://github.com/clcastro87/express-tongue
- Homepage: https://github.com/clcastro87/express-tongue#readme
- Issues: https://github.com/clcastro87/express-tongue/issues
- npm.io page: https://npm.io/package/express-tongue

## Dependencies (1)

- [express](https://npm.io/package/express.md) ^4.22.1

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 2.0.1 (latest) — 2026-11-24
- 2.0.0 — 2026-10-18
- 1.2.0 — 2026-08-13
- 1.0.17 — 2026-03-18
- 1.0.16 — 2026-02-21
- 1.1.0 — 2026-02-01
- 1.0.15 — 2026-01-02
- 1.0.14 — 2025-11-22
- 1.0.13 — 2025-11-19
- 1.0.12 — 2025-07-24
- 1.0.11 — 2025-07-24
- 1.0.10 — 2024-11-21
- 1.0.9 — 2024-07-03
- 1.0.8 — 2023-01-04
- 1.0.7 — 2022-03-07
- … 6 more at https://npm.io/package/express-tongue/versions

## README

# express-tongue

[![NPM version](https://img.shields.io/npm/v/express-tongue.svg?style=flat)](https://www.npmjs.com/package/express-tongue)
[![NPM Downloads](https://img.shields.io/npm/dm/express-tongue.svg)](https://www.npmjs.com/package/express-tongue)
[![Build Status](https://travis-ci.org/clcastro87/express-tongue.svg?branch=master)](https://travis-ci.org/clcastro87/express-tongue)
[![Issues](https://img.shields.io/github/issues/clcastro87/express-tongue.svg)](https://travis-ci.org/clcastro87/express-tongue)
[![GitHub forks](https://img.shields.io/github/forks/clcastro87/express-tongue.svg)](https://github.com/clcastro87/express-tongue/network)
[![GitHub stars](https://img.shields.io/github/stars/clcastro87/express-tongue.svg)](https://github.com/clcastro87/express-tongue/stargazers)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/clcastro87/express-tongue/master/LICENSE)

**Express middleware to handle sites in multiple languages.**

The following localization setup are supported:

  - authenticated user with language attribute
    ```js
    Ex: req.user.language
    ```
  - querystring 
    ```
    Ex: ?hl=en
    ```
  - cookie
  - User-Agent
  - default language

## Install

```bash
$ npm install express-tongue
```

## API

```js
var app = express();
var i18n = require('express-tongue');
app.use(i18n.localize({ 
    endpointEnabled: true, 
    path: __dirname + '/i18n', 
    queryStringEnabled: true
}));
```

### localize([options])

Returns the localization middleware using the given `options`. This middleware injects 
the variable i18n inside res.locals, for usage inside template engines. Also is you are
planning to use localization on client side; for example in SPA, then you have 
several endpoints which helps you to develop a fully localized page.

#### Options

`localize()` accepts these properties in the options object. 

##### defaultLang

Default language abbreviation. Defaults to `en`.

##### path

Directory where localization files are located. Defaults to `WORKING_DIR/i18n`.

##### languages

Replace available languages for those specified in array. This is useful when you want
to deactivate some language.

##### endpointEnabled

Enables API endpoint for usage in client apps. Defaults to `false`

##### endpointPath

Route in which endpoint will be mounted. Defaults to `/i18n`

##### queryStringEnabled

Allows language replacement by setting key in querystring.

##### queryStringKey

Setup key used in querystring to define current language. Defaults to `hl`.

#### langCookie

Cookie name for storing current locale.

## Examples

### express/connect

When using this module with express or connect, simply `app.use` the module as
high as you like. Requests that pass through the middleware will inject `i18n` property 
to res.locals

```js
var i18n = require('compression')
var express = require('express')

var app = express();
var i18n = require('express-tongue');
app.use(i18n.localize({ 
    endpointEnabled: true, 
    path: __dirname + '/i18n', 
    queryStringEnabled: true
}));

app.use('/locals', function(req, res) {
    res.json(res.locals.i18n);
});
```

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/express-tongue · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
