Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

toajs/toa-i18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

toa-i18n

I18n module for toa.

NPM version Build Status Downloads

Wrapped i18n-node v0.5.0

Demo

const Toa = require('toa')
const toaI18n = require('toa-i18n')

const app = new Toa()
app.use(function() {
  this.body = this.__('Hello')
});

toaI18n(app, {
  cookie: 'lang',
  locales:['zh', 'en'],
  directory: './examples/locales'
})
app.listen(3000)

Installation

npm install toa-i18n

API

const toaI18n = require('toa-i18n')

toaI18n(app, options)

It will add __, __n, getLocale, setLocale, getCatalog method to context, And locale getter to context. options is the same as i18n-node.

Licences

(The MIT License)