Make request.language default to 'en'
Add i18n.pages.default using 'en' locale
This commit is contained in:
parent
3bfaf5f3df
commit
0e956f6c67
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue