diff options
author | Samuel <34555296+Flam3rboy@users.noreply.github.com> | 2023-03-17 19:30:54 +0100 |
---|---|---|
committer | Samuel <34555296+Flam3rboy@users.noreply.github.com> | 2023-03-17 19:30:54 +0100 |
commit | cae6fcc72a61608d594b3a7c3077c8e01a0b5045 (patch) | |
tree | 9680129a7718208c07d42d5b05889921d52e2cf9 /src/api/middlewares | |
parent | perf: optimize getPermission() (diff) | |
download | server-cae6fcc72a61608d594b3a7c3077c8e01a0b5045.tar.xz |
fix: request language property
Diffstat (limited to '')
-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, |