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:
parent
5ba7c6b5bc
commit
cae6fcc72a
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user