I want to build a blog with multilang content in Kraken.JS. How should I build the controller/model/routes to get these URLs:
/en-US/article/hello-world
/de-DE/article/hello-world
/it-IT/article/hello-world
The slug (hello-world) does not have to be internationalised. I don't want to copy the controller in files like:
controllers/en-US/article/index.js
controllers/de-DE/article/index.js
controllers/it-IT/article/index.js
Is there a prettier way to do this with just one controller file?
Yes it can be done using a single controller:
Checkout this example for directions on how to accomplish this https://github.com/krakenjs/kraken-example-with-i18n#adding-a-hook-to-set-the-locale-on-the-fly
One way to do this might be the following:
router.get('/:locale/article/:article_name', function (req, res) {
res.cookie('locale', req.params.locale);
res.redirect('/article/:article_name');
});
There would be only one controller:
controller/article/index.js