2.0.11 • Published 4 years ago

@tiny-i18n/express-live v2.0.11

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

@tiny-i18n/express-live

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

Usage

npm i @tiny-i18n/express-live
  • server.js
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
module.exports = {
  // ...
}
  • dict/common.js
module.exports = {
  // ...
}
  • app.js (frontend)
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

2.0.11

4 years ago

2.0.9

4 years ago

2.0.10

4 years ago

2.0.8

4 years ago

2.0.7

4 years ago

2.0.6

4 years ago

2.0.2

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago