# understood

> accept-language plugin for hapi

Latest version **1.0.1** (published 2016-12-30) · MPL-2 license · 0 weekly downloads

## Install

```sh
npm install understood
pnpm add understood
yarn add understood
bun add understood
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-12-30 |
| First published | 2016-12-30 |
| Weekly downloads | 0 |
| License | MPL-2 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Wyatt Preul |
| Maintainers | wyatt |
| Keywords | hapi, plugin, language |

## Links

- npm: https://www.npmjs.com/package/understood
- Repository: https://github.com/geek/understood
- Homepage: https://github.com/geek/understood#readme
- Issues: https://github.com/geek/understood/issues
- npm.io page: https://npm.io/package/understood

## Dependencies (1)

- [accept-language-parser](https://npm.io/package/accept-language-parser.md) 1.3.x

## Recent versions

- 1.0.1 (latest) — 2016-12-30
- 1.0.0 — 2016-12-30

## README

# understood
accept-language parsing plugin for hapi

[![Build Status](https://secure.travis-ci.org/geek/understood.svg)](http://travis-ci.org/geek/understood)


## options

- `locales`: array of available locales that are supported
- `localesDir`: path to directory containing locale files. The available locales are read from the filenames inside of this directory.
- `default`: preferred default locale if a suitable one cannot be found

understood parses the `Accept-Language` header and sets the `request.locale` to the appropriate locale.

## usage

```js
const Hapi = require('hapi');
const Understood = require('understood');


server.register({ register: Understood, options: { localesDir: (__dirname + '/locales'), default: 'fr-CA' } }, (err) => {
  // handle err

  server.route({
    method: 'GET',
    path: '/',
    handler: function (request, reply) {
      reply(request.locale);
    }
  });
});
```

Here are a couple of example curl requests to the above server.

```
$ curl -H 'Accept-Language: en-US' http://serverurl
en-US

$ curl http://serverurl
fr-CA
```

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