sails-routes-helpers-maker
It takes the object with all routes defined in it (sails.js routes) and create path helpers
This module is in beta, use at your own risk.
Usage Example
multilingualRoutes = 'GET /': 'HomeController.show' 'GET /photos/:id/:slug': 'PhotosController.show' 'PUT /photos/:id/:slug': 'NewsController.update' 'DELETE /photos/:id/:slug': 'NewsController.destroy' 'GET /photos': 'PhotosController.index' 'GET /photos/new': 'PhotosController.new' 'GET /photos/:id/:slug/edit': 'PhotosController.edit' 'POST /photos': 'PhotosController.create' 'GET /fotos/:id/:slug': 'PhotosController.show' 'PUT /fotos/:id/:slug': 'NewsController.update' 'DELETE /fotos/:id/:slug': 'NewsController.destroy' 'GET /fotos': 'PhotosController.index' 'GET /fotos/new': 'PhotosController.new' 'GET /fotos/:id/:slug/edit': 'PhotosController.edit' 'POST /fotos': 'PhotosController.create' routeLocales = '/': en: '/'es: '/' '/photos': en: '/photos'es: '/fotos' helpers = helpersMakermakemultilingualRoutesrouteLocales
Creates the following helpers
helpershomePath # returns '/' helpershomePath'es' # returns 'es/' helpersphotosPath # returns /photos helpersphotosPath'es' # returns /es/fotos
An instance to be passed to the multilingual helper should have a toParam method on it, that indicates how and what info should be extracted from it, for example, assume the following record was returned by running a waterline query like this: Photo.findOne(23).exec(....)
photoRecordInstance = id: 23 slug: en: 'amazing-sunrise'es: 'amanecer-espectacular' = "/" helpersphotosPathphotoRecordInstance'en' # returns /photos/23/amazing-sunrise helpersphotosPathphotoRecordInstance'es' # returns /es/fotos/23/amanecer-espectacular helperseditPhotosPath # returns /photos/23/amazing-sunrise/edit helperseditPhotosPath'es' # returns /es/fotos/23/amanecer-espectacular/edit ... yes i need to handle the edit part in the future helpersnewPhotosPath # returns /photos/new