Make request.language default to 'en'

Add i18n.pages.default using 'en' locale
This commit is contained in:
Robbie Antenesse 2020-09-20 17:21:05 -06:00
parent 3bfaf5f3df
commit 0e956f6c67
2 changed files with 2 additions and 3 deletions

View File

@ -36,6 +36,7 @@ async function plugin (fastify, opts, done) {
// Set the default language to English after parsing locales because it has the most coverage.
i18n.default = i18n.en;
i18n.pages.default = i18n.pages.en;
} catch (ex) {
console.error('Could not get locales folder.\n', ex);
}

View File

@ -100,9 +100,7 @@ fastify.addHook('onRequest', async (request, reply) => {
request.user = user;
}
}
if (typeof request.cookies.lang !== 'undefined') {
request.language = request.cookies.lang;
}
request.language = typeof request.cookies.lang !== 'undefined' ? request.cookies.lang : 'en';
});
// Store i18n files in fastify object and register locales routes