# open-i18n

> i18n language locale && i18n.middleWare

Latest version **0.5.0** (published 2017-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install open-i18n
pnpm add open-i18n
yarn add open-i18n
bun add open-i18n
```

Provides the command `open-i18n`.

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2017-07-28 |
| First published | 2016-07-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Redstone Zhao |
| Maintainers | stonephp |
| Keywords | i18n, language, locale, po |

## Links

- npm: https://www.npmjs.com/package/open-i18n
- Repository: https://github.com/open-node/open-i18n
- Homepage: https://github.com/open-node/open-i18n#readme
- Issues: https://github.com/open-node/open-i18n/issues
- npm.io page: https://npm.io/package/open-i18n

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) *

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

- 0.5.0 (latest) — 2017-07-28
- 0.4.0 — 2016-10-09
- 0.3.0 — 2016-10-07
- 0.2.0 — 2016-09-22
- 0.1.0 — 2016-07-18
- 0.0.1 — 2016-07-18

## README

# open-i18n
=================

[![Build status](https://api.travis-ci.org/open-node/open-i18n.svg?branch=master)](https://travis-ci.org/open-node/open-i18n)
[![codecov](https://codecov.io/gh/open-node/open-i18n/branch/master/graph/badge.svg)](https://codecov.io/gh/open-node/open-i18n)

## Quick start
<pre>npm install open-i18n --save</pre>

## Usage
```js
var i18n = require('i18n');

// languages System allow language
// locale Current request use lanuage
// language packages,
/*
  {
    "zh": {
      "hello world": "你好世界。"
    },
    "en": {
      "hello world": "Hello world."
    }
  }
 */
var t = i18n(languages, locale, LANGS).t;

t('hello world'); // return "你好世界"

// middle-ware auto handle res.body when request error
server.use(i18n.middleWare(languages, defaultLanguage, LANGS))
```

## Collect language items
<pre>
  find ./src/app -type f | node_modules/.bin/open-i18n read > bin/locale/application.pot
  msgmerge -UN --no-wrap ./bin/locale/en.po ./bin/locale/application.pot
  msgmerge -UN --no-wrap ./bin/locale/zh.po ./bin/locale/application.pot
</pre>

## Translate language items

Edit `en.po`, `zh.po` to translate.

## Make language package
<pre>
  node_modules/.bin/open-i18n write ./bin/locale/zh.po zh > locale/zh.json
</pre>

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