app.js的相关行:
var contact = require('./routes/contact');
app.all('/:lang/*', function(req, res, next){
var selectedLang = req.params.lang;
i18n.setLocale([req, res.locals], selectedLang);
res.locals.language = selectedLang;
next();
});
app.use('/contact', contact);
app.use('/:lang/contact', contact);
nav.hbs的菜单链接:
<li><a href="{{language}}/contact">{{{__ "Kapcsolat"}}}</a></li>
我得到的输出:
http://127.0.0.1:3000/en/en/contact
预期产出:
http://127.0.0.1:3000/en/contact
出了什么问题?
答案 0 :(得分:1)
更改您的nav.hbs,将其用作菜单链接:
<li><a href="/{{language}}/contact">{{{__ "Kapcsolat"}}}</a></li>