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) => {
|
router.use((req, res, next) => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
||||||
req.t = (key: string | string[], options?: any) => {
|
|
||||||
let lng = "en";
|
let lng = "en";
|
||||||
if (req.headers["accept-language"]) {
|
if (req.headers["accept-language"]) {
|
||||||
lng = req.headers["accept-language"].split(",")[0];
|
lng = req.headers["accept-language"].split(",")[0];
|
||||||
}
|
}
|
||||||
req.language = lng;
|
req.language = lng;
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
req.t = (key: string | string[], options?: any) => {
|
||||||
return i18next.t(key, {
|
return i18next.t(key, {
|
||||||
...options,
|
...options,
|
||||||
lng,
|
lng,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user