How to add global parameters to Meteor Iron Router? -


i can specify specific route in iron router

router.path('/:lang/path') 

and change language according :lang parameter in beforeaction().

how can on global scale, e.g. every path should have :lang prefix?

(and yes know there iron-router-i18n package this, cannot use in context).

here's 1 pattern might efficiently:

var myroutes = ['about','info','help','item','post']; // list of layouts (use own names)  myroutes.foreach(function(r){ // create routes /:lang/routename   router.route(':lang/'+r,{ name: r, controller: 'mycontroller' }); });  mycontroller = routecontroller.extend({ // define own controller   onbeforeaction: function(){     session.set('language',this.params.lang); // set language   } }); 

Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -