feat: web i18n (#1286)
This commit is contained in:
@@ -5,9 +5,10 @@ import { NextResponse } from 'next/server';
|
||||
import { getToken } from 'next-auth/jwt';
|
||||
|
||||
import { TEAM_URL_ROOT_REGEX } from '@documenso/lib/constants/teams';
|
||||
import { extractSupportedLanguage } from '@documenso/lib/utils/i18n';
|
||||
import { formatDocumentsPath } from '@documenso/lib/utils/teams';
|
||||
|
||||
export default async function middleware(req: NextRequest) {
|
||||
async function middleware(req: NextRequest): Promise<NextResponse> {
|
||||
const preferredTeamUrl = cookies().get('preferred-team-url');
|
||||
|
||||
const referrer = req.headers.get('referer');
|
||||
@@ -78,6 +79,19 @@ export default async function middleware(req: NextRequest) {
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
export default async function middlewareWrapper(req: NextRequest) {
|
||||
const response = await middleware(req);
|
||||
|
||||
const lang = extractSupportedLanguage({
|
||||
headers: req.headers,
|
||||
cookies: cookies(),
|
||||
});
|
||||
|
||||
response.cookies.set('i18n', lang);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: [
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user