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>
This commit is contained in:
parent
5aa959eea4
commit
15bca54bdf
@ -59,7 +59,7 @@ router.get(['/a', '/a/*'], (req, res, next) => {
|
|||||||
*/
|
*/
|
||||||
router.get(['/d', '/d/*'], async (req, res, next) => {
|
router.get(['/d', '/d/*'], async (req, res, next) => {
|
||||||
const pageArgs = pageHelper.parsePath(req.path, { stripExt: true })
|
const pageArgs = pageHelper.parsePath(req.path, { stripExt: true })
|
||||||
|
|
||||||
const versionId = (req.query.v) ? _.toSafeInteger(req.query.v) : 0
|
const versionId = (req.query.v) ? _.toSafeInteger(req.query.v) : 0
|
||||||
|
|
||||||
const page = await WIKI.models.pages.getPageFromDb({
|
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}`)
|
return res.redirect(`/e/${pageArgs.locale}/${pageArgs.path}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
req.i18n.changeLanguage(pageArgs.locale)
|
||||||
|
|
||||||
// -> Set Editor Lang
|
// -> Set Editor Lang
|
||||||
_.set(res, 'locals.siteConfig.lang', pageArgs.locale)
|
_.set(res, 'locals.siteConfig.lang', pageArgs.locale)
|
||||||
_.set(res, 'locals.siteConfig.rtl', req.i18n.dir() === 'rtl')
|
_.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) {
|
if (WIKI.config.lang.namespacing && !pageArgs.explicitLocale) {
|
||||||
return res.redirect(`/h/${pageArgs.locale}/${pageArgs.path}`)
|
return res.redirect(`/h/${pageArgs.locale}/${pageArgs.path}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
req.i18n.changeLanguage(pageArgs.locale)
|
||||||
|
|
||||||
_.set(res, 'locals.siteConfig.lang', pageArgs.locale)
|
_.set(res, 'locals.siteConfig.lang', pageArgs.locale)
|
||||||
_.set(res, 'locals.siteConfig.rtl', req.i18n.dir() === 'rtl')
|
_.set(res, 'locals.siteConfig.rtl', req.i18n.dir() === 'rtl')
|
||||||
|
Loading…
Reference in New Issue
Block a user