status-i18n
!NPM Versionnpm-imagenpm-url
!NPM Downloadsdownloads-imagedownloads-url
!Node.js Versionnode-version-imagenode-version-url
!Build Statustravis-imagetravis-url
!Test Coveragecoveralls-imagecoveralls-urlHTTP status and message mapping, i18n supported.
Installation
$ npm install @http-util/status-i18n
API
var status = require('@http-util/status-i18n');
// or
import status from '@http-util/status-i18n';
status.BROWSERLANG
Returns a lowercase string of default browser language set by user.status.codes
Returns an array of all the status codes asInteger
s.statuscode
Map ofcode
to status message
, in the same format as the Node.js http module. undefined
for invalid code
s. The language has been set to default en-us
.status[404] // => 'Not Found'
status[700] // => undefined
status(code, language)
Map ofcode
to status message
with specific language. The default browser language is assumed to be en-us
.status(401, 'zh-cn') // => '无权限'
status(401, 'zh-CN') // => '无权限'
status(401, 'zh') // => '无权限'
status(401, status.BROWSER_LANG) // => 'Unauthorized'
status(401) // => 'Unauthorized'