# connect-gettext

> Lightweight implementation of gettext as connect middleware.

Latest version **3.0.1** (published 2025-12-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install connect-gettext
pnpm add connect-gettext
yarn add connect-gettext
bun add connect-gettext
```

## Health

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

Positive: esm support; no vulnerabilities; has provenance.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 3.0.1 |
| Published | 2025-12-26 |
| First published | 2015-05-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 2 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Author | Damian Krzeminski |
| Maintainers | pirxpilot |
| Keywords | connect-gettext, i18n, l10n, translation, gettext, connect, po |

## Links

- npm: https://www.npmjs.com/package/connect-gettext
- Repository: https://github.com/pirxpilot/connect-gettext
- Homepage: https://github.com/pirxpilot/connect-gettext#readme
- Issues: https://github.com/pirxpilot/connect-gettext/issues
- npm.io page: https://npm.io/package/connect-gettext

## Dependencies (2)

- [debug](https://npm.io/package/debug.md) ~4
- [gettext-parser](https://npm.io/package/gettext-parser.md) ~9

## 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

- 3.0.1 (latest) — 2025-12-26
- 3.0.0 — 2025-12-25
- 2.1.1 — 2025-05-19
- 2.1.0 — 2024-01-31
- 2.0.0 — 2020-03-29
- 1.1.1 — 2017-02-17
- 1.1.0 — 2017-02-15
- 1.0.0 — 2015-05-09
- 0.0.0 — 2015-05-09

## README

[![NPM version][npm-image]][npm-url]
[![Build Status][build-image]][build-url]
[![Dependency Status][deps-image]][deps-url]

# connect-gettext

Lightweight implementation of gettext as connect middleware.

## Install

```sh
$ npm install --save connect-gettext
```

## Usage

Use with any middleware that sets `req.lang` - such as [detect-language] and/or [overwrite-language].

```js
var app = require('express');

var locale = {
  supportedLanguages: ['de', 'fr', 'pl', 'en-GB', 'en-US'],
  defaultLanguage: 'en',
  gettextAlias: '_'
};

// use any middleware that sets req.lang
// `detect-language` is just an example
app.use(require('detect-language')(locale));


app.use(require('connect-gettext')(locale));

```

Once the middleware is applied `res.locals.gettext` will have `gettext` implementation inserted
and `res.render` will be able to use it when rendering pages.

```jade
 p
   | #{_("This is how you can use it")}
   span= _("with Jade")
```

## License

MIT © [Damian Krzeminski](https://pirxpilot.me)

[detect-language]: https://npmjs.org/package/detect-language
[overwrite-language]: https://npmjs.org/package/overwrite-language

[npm-image]: https://img.shields.io/npm/v/connect-gettext
[npm-url]: https://npmjs.org/package/connect-gettext

[build-url]: https://github.com/pirxpilot/connect-gettext/actions/workflows/check.yaml
[build-image]: https://img.shields.io/github/actions/workflow/status/pirxpilot/connect-gettext/check.yaml?branch=main

[deps-image]: https://img.shields.io/librariesio/release/npm/connect-gettext
[deps-url]: https://libraries.io/npm/connect-gettext

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