Skip to content

Commit

Permalink
i18n support
Browse files Browse the repository at this point in the history
  • Loading branch information
openhoat committed Dec 14, 2015
1 parent ccc9bcb commit 94c9718
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lib/hw-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,12 @@ that = {
} else {
data = {code: errorCode, message: 'internal error'};
}
if (req && req.t && data.message) {
data.message = req.t(data.message, _.extend({lng: req.lng}, reqParams));
if (data.message) {
if (req && req.t) { // i18next handler
data.message = req.t(data.message, _.extend({lng: req.lng}, reqParams));
} else if (res && res.__) { // i18n handler
data.message = req.__(data.message);
}
}
if (logger.enabledLevels.debug) {
log.debug('%ssending error :', res.headersSent ? 'NOT ' : '', error);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hw-error",
"version": "0.1.8",
"version": "0.1.9",
"description": "Better error management",
"main": "lib/hw-error.js",
"author": "Olivier Penhoat <openhoat@gmail.com> (http://headwood.net/)",
Expand Down

0 comments on commit 94c9718

Please sign in to comment.