1.0.3 • Published 6 years ago

http-code-translator v1.0.3

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

Http code translator

Translate http code into your languange.

Install

npm install --save http-code-translator

or

yarn add http-code-translator

Usage

// load the module
const HttpCodeTranslator = require('http-code-translator');

// current support language is English and Chinese
const codeTranslator = new HttpCodeTranslator('en');

// load language manually
// Language code is ISO 639-1
codeTranslator.loadLanguage('zh');
// or load the translation map
codeTranslator.loadTranslation({
  // must have a default value when code not found
  defaultValue: 'Unknown value',
  200: 'OK',
});

// translate code
codeTranslator.translate(200);   // OK
codeTranslator.translate("200"); // OK
codeTranslator.translate("299"); // Unkonw value

// Set default value
codeTranslator.setDefaultValue("The code is unknown");
codeTranslator.translate("299"); // The code is unknown

Typings

Typings is set in index.d.ts for typescript or code in VS code.

LICENSE

MIT

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago