# @repit/lambda-localize

> AWS Lambda response localization.

Latest version **1.0.6** (published 2017-12-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @repit/lambda-localize
pnpm add @repit/lambda-localize
yarn add @repit/lambda-localize
bun add @repit/lambda-localize
```

## 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.6 |
| Published | 2017-12-17 |
| First published | 2017-12-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ion Suman |
| Maintainers | sumanion |

## Links

- npm: https://www.npmjs.com/package/@repit/lambda-localize
- npm.io page: https://npm.io/package/@repit/lambda-localize

## Dependencies (2)

- [@repit/lambda-send](https://npm.io/package/@repit/lambda-send.md) ^1.0.1
- [@repit/lambda-query](https://npm.io/package/@repit/lambda-query.md) ^1.0.0

## Recent versions

- 1.0.6 (latest) — 2017-12-17
- 1.0.5 — 2017-12-17
- 1.0.4 — 2017-12-16
- 1.0.3 — 2017-12-16
- 1.0.2 — 2017-12-16
- 1.0.1 — 2017-12-16
- 1.0.0 — 2017-12-16

## README

# Lambda Localize

AWS Lambda response localization.

## Installation

```bash
$ npm install @repit/lambda-localize --save
```

## Usage

```js
'use strict'

// Load the Localize class.
const Localize = require('@repit/lambda-localize')

exports.handler = (event, context, callback) => {
  // Create a new Localize object.
  const localize = new Localize(callback)

  // Send a localized response with default structure.
  localize.send(200, 'Message:UserCreated', 'fr')

  // Send a localized response with custom structure.
  localize.send(200, 'Message:UserCreated', 'fr', message => ({
    message,
    userId: 1000000,
  }))
}
```

## Localization

Localization is done using [@repit/lambda-query](https://www.npmjs.com/package/@repit/lambda-query) package.
For details about how it works see the package page.

## Response Structure

Responses are sent using [@repit/lambda-send](https://www.npmjs.com/package/@repit/lambda-send) package.
Details about how response is formatted can be found on the package page.

## Caching

By default `Localize` class does not do any caching, but it can internally forward the `Cache (@repit/lambda-cache)` object to the `Query (@repit/lambda-query)` object and all localization queries will be cached.

*Here is a basic example on how to use caching:*

```js
'use strict'

const Localize = require('@repit/lambda-localize')
const Cache = require('@repit/lambda-cache')

const cache = new Cache()

exports.handler (event, context, callback) => {
  const localize = new Localize(callback, cache)
}
```

> For more details about caching see [@repit/lambda-cache](https://www.npmjs.com/package/@repit/lambda-cache) package.

## License

MIT

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