diff --git a/app.js b/app.js index 134deb4..1b5ccb7 100644 --- a/app.js +++ b/app.js @@ -86,6 +86,8 @@ const csrfProtection = csrf({ cookie: true }); app.use(csrfProtection); app.use(/\/(fr|en)/i, indexRouter); app.use(/\/(fr|en)\/auth/i, authRouter); +app.use("/", indexRouter); +app.use("/auth", authRouter); // catch 404 and forward to error handler app.use(function (req, res, next) { diff --git a/controllers/auth.js b/controllers/auth.js index 6a51805..95edb5c 100644 --- a/controllers/auth.js +++ b/controllers/auth.js @@ -7,7 +7,10 @@ function indexPage(req, res) { } function loginPage(req, res) { - res.render('auth/login'); + res.render('auth/login', { + title: req.i18n.__("SoundBirder - Login"), + locale: req.i18n.locale + }); } function login(req, res) { @@ -19,11 +22,14 @@ function logout(req, res) { } function registerPage(req, res) { - res.render('auth/register'); + res.render('auth/register', { + title: req.i18n.__("SoundBirder - Register"), + locale: req.i18n.locale + }); } function register(req, res) { - + } function forgotPassword(req, res) { diff --git a/controllers/index.js b/controllers/index.js index b085744..6b73cfd 100644 --- a/controllers/index.js +++ b/controllers/index.js @@ -2,12 +2,16 @@ function getIndex(req, res) { res.render('index', { title: 'SoundBirder', - csrf_token: req.csrfToken() + csrf_token: req.csrfToken(), + locale: req.i18n.locale }); } function getAbout(req, res) { - res.render('about', { title: 'About SoundBirder' }); + res.render('about', { + title: 'About SoundBirder', + locale: req.i18n.locale + }); } module.exports = { diff --git a/views/layout.pug b/views/layout.pug index 70b1065..35298d0 100644 --- a/views/layout.pug +++ b/views/layout.pug @@ -10,11 +10,12 @@ html header h1= title nav + - var i18n_prefix = locale ? '/' + locale : '' ul li - a(href="/") #{ __("Game") } + a(href=`${i18n_prefix}/`) #{ __("Game") } li - a(href="/about") #{ __("About") } + a(href=`${i18n_prefix}/about`) #{ __("About") } main block content footer