1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-10 04:32:35 +01:00

fix: request language property

This commit is contained in:
Samuel 2023-03-17 19:30:54 +01:00
parent 5ba7c6b5bc
commit cae6fcc72a

View File

@ -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,