Skip to content

Commit

Permalink
fix: change language in edit, history and source pages (#2194)
Browse files Browse the repository at this point in the history
* change language in edit, history and source pages

* fix: remove unnecessary i18n locale switch for download page

Co-authored-by: Nicolas Giard <github@ngpixel.com>
  • Loading branch information
sesajad and NGPixel committed Jul 29, 2020
1 parent 5aa959e commit 15bca54
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/controllers/common.js
Expand Up @@ -59,7 +59,7 @@ router.get(['/a', '/a/*'], (req, res, next) => {
*/
router.get(['/d', '/d/*'], async (req, res, next) => {
const pageArgs = pageHelper.parsePath(req.path, { stripExt: true })

const versionId = (req.query.v) ? _.toSafeInteger(req.query.v) : 0

const page = await WIKI.models.pages.getPageFromDb({
Expand Down Expand Up @@ -107,6 +107,8 @@ router.get(['/e', '/e/*'], async (req, res, next) => {
return res.redirect(`/e/${pageArgs.locale}/${pageArgs.path}`)
}

req.i18n.changeLanguage(pageArgs.locale)

// -> Set Editor Lang
_.set(res, 'locals.siteConfig.lang', pageArgs.locale)
_.set(res, 'locals.siteConfig.rtl', req.i18n.dir() === 'rtl')
Expand Down Expand Up @@ -237,6 +239,8 @@ router.get(['/h', '/h/*'], async (req, res, next) => {
if (WIKI.config.lang.namespacing && !pageArgs.explicitLocale) {
return res.redirect(`/h/${pageArgs.locale}/${pageArgs.path}`)
}

req.i18n.changeLanguage(pageArgs.locale)

_.set(res, 'locals.siteConfig.lang', pageArgs.locale)
_.set(res, 'locals.siteConfig.rtl', req.i18n.dir() === 'rtl')
Expand Down

0 comments on commit 15bca54

Please sign in to comment.