fix: change language in edit, history and source pages (#2194)

* 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>
pull/2269/head
Seyed Sajad Kahani 4 years ago committed by GitHub
parent 5aa959eea4
commit 15bca54bdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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({
@ -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')
@ -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')

Loading…
Cancel
Save