summary refs log tree commit diff
diff options
context:
space:
mode:
authorSamuel <34555296+Flam3rboy@users.noreply.github.com>2023-03-17 19:30:54 +0100
committerSamuel <34555296+Flam3rboy@users.noreply.github.com>2023-03-17 19:30:54 +0100
commitcae6fcc72a61608d594b3a7c3077c8e01a0b5045 (patch)
tree9680129a7718208c07d42d5b05889921d52e2cf9
parentperf: optimize getPermission() (diff)
downloadserver-cae6fcc72a61608d594b3a7c3077c8e01a0b5045.tar.xz
fix: request language property
-rw-r--r--src/api/middlewares/Translation.ts11
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,