Revert "fix(language): prefer session data over request data"

This reverts commit 86d6580ffb.
This commit is contained in:
SabreCat
2021-11-17 10:46:46 -06:00
parent 79033af36e
commit b943f4bc7f

View File

@@ -19,6 +19,12 @@ export function attachTranslateFunction (req, res, next) {
}
export function getUserLanguage (req, res, next) {
// In case the language is specified in the request url, use intersection
if (req.query.lang) {
req.language = translations[req.query.lang] ? req.query.lang : 'en';
return next();
}
// If the request is authenticated, use the user's preferred language
if (res.locals && res.locals.user) {
req.language = getLanguageFromUser(res.locals.user, req);
@@ -39,12 +45,6 @@ export function getUserLanguage (req, res, next) {
.catch(next);
}
// In case the language is specified in the request url, use intersection
if (req.query.lang) {
req.language = translations[req.query.lang] ? req.query.lang : 'en';
return next();
}
// Otherwise get from browser
req.language = getLanguageFromBrowser(req);
return next();