move to nuxt-i18n, switch language,address #171

This commit is contained in:
lesion
2022-10-12 12:45:09 +02:00
parent 33084237e9
commit 2cb4359ffd
13 changed files with 59 additions and 48 deletions

View File

@@ -63,13 +63,6 @@ module.exports = {
})
},
async setUserLocale(req, res, next) {
// select locale based on cookie? and accept-language header
acceptLanguage.languages(Object.keys(locales))
res.locals.acceptedLocale = acceptLanguage.get(req.headers['accept-language'])
dayjs.locale(res.locals.acceptedLocale)
next()
},
async initSettings(_req, res, next) {
// initialize settings

View File

@@ -5,7 +5,6 @@ const initialize = require('./initialize.server')
const config = require('./config')
const helpers = require('./helpers')
app.use(helpers.setUserLocale)
app.use(helpers.initSettings)
app.use(helpers.logRequest)
app.use(helpers.serveStatic())
@@ -73,10 +72,9 @@ async function main () {
// remaining request goes to nuxt
// first nuxt component is ./pages/index.vue (with ./layouts/default.vue)
// prefill current events, tags, places and announcements (used in every path)
app.use(async (_req, res, next) => {
if (config.status === 'READY') {
// TODO: fetch into layout!
const announceController = require('./api/controller/announce')
res.locals.announcements = await announceController._getVisible()
}