# @tiny-i18n/express-live

> The express router about tiny-i18n's edit live.

Latest version **2.0.11** (published 2020-07-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @tiny-i18n/express-live
pnpm add @tiny-i18n/express-live
yarn add @tiny-i18n/express-live
bun add @tiny-i18n/express-live
```

## 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 | 2.0.11 |
| Published | 2020-07-05 |
| First published | 2018-06-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 24.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | imcuttle |
| Maintainers | moyuyc |

## Links

- npm: https://www.npmjs.com/package/@tiny-i18n/express-live
- Repository: https://github.com/imcuttle/tiny-i18n
- Homepage: https://github.com/imcuttle/tiny-i18n#readme
- Issues: https://github.com/imcuttle/tiny-i18n/issues
- npm.io page: https://npm.io/package/@tiny-i18n/express-live

## Dependencies (2)

- [body-parser](https://npm.io/package/body-parser.md) ^1.18.3
- [@tiny-i18n/fs](https://npm.io/package/@tiny-i18n/fs.md) ^2.2.4

## Recent versions

- 2.0.11 (latest) — 2020-07-05
- 2.0.10 — 2020-07-04
- 2.0.9 — 2020-07-04
- 2.0.8 — 2020-07-04
- 2.0.7 — 2020-07-03
- 2.0.6 — 2020-07-03
- 2.0.5 — 2020-07-03
- 2.0.4 — 2020-07-03
- 2.0.2 — 2020-07-03
- 2.0.1 — 2020-07-03
- 2.0.0 — 2020-07-03
- 1.1.2 — 2018-08-27
- 1.1.1 — 2018-08-27
- 1.1.0 — 2018-07-01
- 1.0.3 — 2018-06-23
- … 2 more at https://npm.io/package/@tiny-i18n/express-live/versions

## README

# @tiny-i18n/express-live

The express router about tiny-i18n's edit live.

## Usage

```bash
npm i @tiny-i18n/express-live
```

- server.js

```javascript
const express = require('express')
const live = require('@tiny-i18n/express-live')
const app = express()

app.use('/i18n/', live(__dirname + '/dict', /* options */))
app.listen(9999, () => {
  console.log('Server run on Port: 9999.')
})
```

- dict/common.js

```javascript
module.exports = {
  // ...
}
```

- dict/common.js

```javascript
module.exports = {
  // ...
}
```


- app.js (frontend)

```javascript
import '@tiny-i18n/react-live/register'
import { transaction, Provider, inject } from '@tiny-i18n/react-live'
import { setDictionary, getLanguages, getCurrentLanguage, i18n, getDictionary } from 'tiny-i18n'

import * as React from 'react'
import * as ReactDOM from 'react-dom'
import '@tiny-i18n/react-live/lib/style.css'

let zhDict = require('./dict/zh-CN')
let enDict = require('./dict/en-US')
setDictionary(zhDict, 'zh-CN')
setDictionary(enDict, 'en-US')

transaction.setConfig({
  fetchUpdate({ lang, key, value }) {
    return fetch('/i18n/update', {
      method: 'POST',
      headers: {
        'content-type': 'application/json'
      },
      body: JSON.stringify({ lang, key, value })
    }).then(res => res.json())
      .then(json => {
        console.log(json)
      })
  }
})

ReactDOM.render(
  // ...
)
```

## Options

Same as [@tiny-i18n/fs](../fs)

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