diff options
Diffstat (limited to 'src/api/middlewares/Translation.ts')
-rw-r--r-- | src/api/middlewares/Translation.ts | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/api/middlewares/Translation.ts b/src/api/middlewares/Translation.ts index bf6ea034..0e292962 100644 --- a/src/api/middlewares/Translation.ts +++ b/src/api/middlewares/Translation.ts @@ -57,13 +57,14 @@ export async function initTranslation(router: Router) { }); router.use((req, res, next) => { + let lng = "en"; + if (req.headers["accept-language"]) { + lng = req.headers["accept-language"].split(",")[0]; + } + req.language = lng; + // eslint-disable-next-line @typescript-eslint/no-explicit-any req.t = (key: string | string[], options?: any) => { - let lng = "en"; - if (req.headers["accept-language"]) { - lng = req.headers["accept-language"].split(",")[0]; - } - req.language = lng; return i18next.t(key, { ...options, lng, |