# js-language-error

> This package will let you translate errors to different languages.

Latest version **1.0.0** (published 2020-04-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install js-language-error
pnpm add js-language-error
yarn add js-language-error
bun add js-language-error
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-04-19 |
| First published | 2020-04-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Moshe Wainner |
| Maintainers | darkshot |

## Links

- npm: https://www.npmjs.com/package/js-language-error
- Repository: https://github.com/Moshewiner/JS-Language-Error
- Homepage: https://github.com/Moshewiner/JS-Language-Error#readme
- Issues: https://github.com/Moshewiner/JS-Language-Error/issues
- npm.io page: https://npm.io/package/js-language-error

## Recent versions

- 1.0.0 (latest) — 2020-04-19

## README

# Javascript Language Error Package
✔ For bored developers, from bored developer.

# How to use it

### config.js
Contains the defaults configuration like: 
```javascript
module.exports = {
    language: 'hebrew', // The selected language
    translations: {
        hebrew: { // The key could be anything, add your language here 😊
            // The translation is <from>: <to>, you should use real js errors for your key.
            'null': 'ערך ריק',
        },
        french: {},
        klingone: {}
    },
};
```
### index.js / your code
You should use the error as:

```javascript 
    try {
        // This section will throw an error (I hope not)        
    }
    catch (err) {
        // The usage of HebrewError is like:
        throw new HebrewError(err);
    }

```

# The exception will look like:
```javascript
HebrewError: אינני יכול להחיל את סגולה 'gever' מ ערך ריק
```

# Add Your Language

set your environment 'JS_LANGUAGE_ERROR_LANGUAGES' with JSON.stringify(...) of your language translation object.
```javascript
JSON.stringify({
    hebrew: {
        'of': 'מ',
        'null': 'ערך ריק',
        'property': 'סגולה',
        'defined': 'הוצהר',
        'is not': 'אינו',
        'unexpected token': 'אנלא ציפיתי לאסימון',
        'cannot read': 'לא ניתן לקרא את',
        'Cannot set': 'אינני יכול להחיל את',
        'maximum': 'תקרה עליונה',
        'exceeded': 'הוחרגה',
        'object': 'אובייקט',
        'at': 'ב',
        'error': 'שגיאה',
        'exception': 'חריגה',
    }
})
```
### For example:
```batch
set JS_LANGUAGE_ERROR_LANGUAGES='{"hebrew":{"of":"מ","null":"ערך ריק","property":"סגולה","defined":"הוצהר","is not":"אינו","unexpected token":"אנלא ציפיתי לאסימון","cannot read":"לא ניתן לקרא את","Cannot set":"אינני יכול להחיל את","maximum":"תקרה עליונה","exceeded":"הוחרגה","object":"אובייקט","at":"ב","error":"שגיאה","exception":"חריגה"}}'
```

# Select language
set your environment 'JS_LANGUAGE_ERROR_SELECTED' with the name of your language (as specified as key in the languages object).### For example:
```batch
set JS_LANGUAGE_ERROR_SELECTED='hebrew'
```

---
_Source: https://npm.io/package/js-language-error · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
