我想用Kraken.JS构建一个包含多路内容的博客。我应该如何构建控制器/模型/路径来获取这些URL:
/en-US/article/hello-world
/de-DE/article/hello-world
/it-IT/article/hello-world鼻涕虫(hello-world)不需要国际化。我不想在以下文件中复制控制器:
controllers/en-US/article/index.js
controllers/de-DE/article/index.js
controllers/it-IT/article/index.js是否有更好的方法来实现这一点,只使用一个控制器文件?
发布于 2016-06-04 18:22:30
是的,可以使用单个控制器来完成:
查看此示例以了解如何完成此https://github.com/krakenjs/kraken-example-with-i18n#adding-a-hook-to-set-the-locale-on-the-fly的说明。
这样做的一种方法可能是:
router.get('/:locale/article/:article_name', function (req, res) {
res.cookie('locale', req.params.locale);
res.redirect('/article/:article_name');
});只有一个控制器:controller/article/index.js
https://stackoverflow.com/questions/37158435
复制相似问题