Organizational Research By

Surprising Reserch Topic

sailsjs change localization

sailsjs change localization  using -'javascript,node.js,localization,sails.js'

I've been using Sails.js for quite some time and was wondering if there is a way to manually change the localization from the controllers depending on the url.

Example: will return the English version and will return the German one.

Thanks for your help!!

asked Sep 18, 2015 by gauravg.gwl
0 votes

Related Hot Questions

1 Answer

0 votes

You can always change the locale in a controller action by using req.setLocale() or by setting the value of req.locale. You can also handle this more globally by using a policy:

// config/routes.js

module.export.routes = {

  '/:lang/': 'MyController.index',
  '/:lang/help': '',
  '/:lang/contact': '',


// config/policies.js

module.exports.policies = {

   '*' : 'localize'


// api/policies/localize.js

module.exports = function(req, res, next) {


answered Sep 18, 2015 by mcasudhir