Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-locale

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-locale

Get locale variable from query, subdomain, the last domain, accept-languages or cookie for koa.

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

koa-locale

Get locale variable from query, subdomain, the last domain, accept-languages or cookie for koa.

NPM version Build status Test coverage License Dependency status

Installation

$ npm install koa-locale

Usage

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();
});

API

ctx.getLocaleFromQuery(), ctx.request.getLocaleFromQuery()
/?locale=en-US
ctx.getLocaleFromSubdomain(), ctx.request.getLocaleFromSubdomain()
zh-CN.koajs.com
ctx.getLocaleFromHeader(multi = false), ctx.request.getLocaleFromHeader(multi = false)
Accept-Language: zh-CN,zh;q=0.5
ctx.getLocaleFromCookie(), ctx.request.getLocaleFromCookie()
Cookie: locale=zh-TW
ctx.getLocaleFromUrl(options), ctx.request.getLocaleFromUrl(options)
http://koajs.com/en
options = { offset: 2 }

http://koajs.com/foo/bar/en
ctx.getLocaleFromTLD(), ctx.request.getLocaleFromTLD()
http://koajs.com/
http://koajs.cn/
http://koajs.it/

License

MIT

Keywords

FAQs

Package last updated on 12 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc