feat(errors): dynamic fallback locale

This commit is contained in:
Benedikt Rötsch
2018-02-14 16:15:02 +01:00
committed by Benedikt Rötsch
parent 92fcbdf4d8
commit 3c9089af98
3 changed files with 45 additions and 17 deletions

6
app.js
View File

@@ -11,7 +11,7 @@ const helmet = require('helmet')
require('dotenv').config({ path: 'variables.env' })
const helpers = require('./helpers')
const { translate, initializeTranslations } = require('./i18n/i18n')
const { translate, initializeTranslations, setFallbackLocale } = require('./i18n/i18n')
const breadcrumb = require('./lib/breadcrumb')
const { updateCookie } = require('./lib/cookies')
const settings = require('./lib/settings')
@@ -110,6 +110,10 @@ app.use(catchErrors(async function (request, response, next) {
response.locals.currentLocale = defaultLocale
}
if (response.locals.fallbackCode) {
setFallbackLocale(response.locals.fallbackCode)
}
// Creates a query string which adds the current credentials to links
// To other implementations of this app in the about modal
helpers.updateSettingsQuery(request, response, response.locals.settings)