![]() | Name | Last modified | Size | Description |
---|---|---|---|---|
![]() | Parent Directory | - | ||
![]() | package.json | 2 years ago | 2.0K | |
![]() | index.js | 8 years ago | 2.0K | |
![]() | README.md | 8 years ago | 2.0K | |
![]() | LICENSE | 8 years ago | 1.1K |
Get locale variable from query, subdomain, the last domain, accept-languages or cookie for koa.
$ npm install koa-locale
var app = require('koa')();
var locale = require('koa-locale');
// the locale key name defaults to `locale`
locale(app, 'language');
app.use(function *(next) {
// query: '?language=en'
this.body = this.getLocaleFromQuery();
});
/?locale=en-US
zh-CN.koajs.com
Accept-Language: zh-CN,zh;q=0.5
Cookie: locale=zh-TW
http://koajs.com/en
options = { offset: 2 }
http://koajs.com/foo/bar/en
http://koajs.com/
http://koajs.cn/
http://koajs.it/
MIT