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
Post a Comment