Skip to content

Commit

Permalink
Update comments to reflect that req.setLocale() is fully supported as…
Browse files Browse the repository at this point in the history
… of Sails v1.0 and beyond.
  • Loading branch information
mikermcneil committed Mar 21, 2018
1 parent 0753a99 commit ce95c84
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/hooks/i18n/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,15 @@ module.exports = function(sails) {
// Mix translation capabilities into res.locals.
i18nFactory.registerMethods(res.locals, req);

// Add `i18n` method as alias to `__` for backwards compatibility.
res.locals.i18n = res.locals.__;
// Add `setLocale()` method for convenience.
// (This is documented and fully supported as of Sails v1.0 and beyond.)
req.setLocale = req.i18n.setLocale.bind(req.i18n);

// Add `getLocale()` and `setLocale()` methods to `req` for backwards compatibility.
// For backwards compatibility:
// • Add `i18n` method as alias to `__`
// • Add `getLocale()` method to `req`
res.locals.i18n = res.locals.__;
req.getLocale = req.i18n.getLocale.bind(req.i18n);
req.setLocale = req.i18n.setLocale.bind(req.i18n);

} catch (e) {
// Seeing as we have a valid i18n singleton already, the
Expand Down

0 comments on commit ce95c84

Please sign in to comment.