mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-12 08:25:47 +01:00
🐛 Fix slug page and refactor server side translations code
This commit is contained in:
19
src/tools/getServerSideTranslations.ts
Normal file
19
src/tools/getServerSideTranslations.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { getCookie } from 'cookies-next';
|
||||
import { IncomingMessage, ServerResponse } from 'http';
|
||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
||||
|
||||
export const getServerSideTranslations = async (
|
||||
req: IncomingMessage,
|
||||
res: ServerResponse,
|
||||
namespaces: string[],
|
||||
requestLocale?: string
|
||||
) => {
|
||||
const configLocale = getCookie('config-locale', { req, res });
|
||||
|
||||
const translations = await serverSideTranslations(
|
||||
(configLocale ?? requestLocale ?? 'en') as string,
|
||||
namespaces
|
||||
);
|
||||
|
||||
return translations;
|
||||
};
|
||||
Reference in New Issue
Block a user