1.0.0 ā¢ Published 4 years ago
js-language-error v1.0.0
Javascript Language Error Package
ā For bored developers, from bored developer.
How to use it
config.js
Contains the defaults configuration like:
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:
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:
HebrewError: ××× × × ×××× ××××× ××Ŗ ×”×××× 'gever' × ×¢×Ø× ×Ø×ק
Add Your Language
set your environment 'JS_LANGUAGE_ERROR_LANGUAGES' with JSON.stringify(...) of your language translation object.
JSON.stringify({
hebrew: {
'of': '×',
'null': '×¢×Ø× ×Ø×ק',
'property': '×”××××',
'defined': '××צ××Ø',
'is not': '××× ×',
'unexpected token': '×× ×× ×¦×פ××Ŗ× ×××”××××',
'cannot read': '×× × ××Ŗ× ×ק×Ø× ××Ŗ',
'Cannot set': '××× × × ×××× ××××× ××Ŗ',
'maximum': '×Ŗק×Ø× ×¢×××× ×',
'exceeded': '××××Ø××',
'object': '×××××ק×',
'at': '×',
'error': 'ש××××',
'exception': '××Ø×××',
}
})
For example:
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:
set JS_LANGUAGE_ERROR_SELECTED='hebrew'
1.0.0
4 years ago