This commit is contained in:
David Nguyen
2025-02-03 19:52:23 +11:00
parent b2af10173a
commit 8bffa7c3ed
40 changed files with 1012 additions and 979 deletions

View File

@ -8,6 +8,11 @@ import { renderToPipeableStream } from 'react-dom/server';
import type { AppLoadContext, EntryContext } from 'react-router';
import { ServerRouter } from 'react-router';
import { APP_I18N_OPTIONS } from '@documenso/lib/constants/i18n';
import { dynamicActivate, extractLocaleData } from '@documenso/lib/utils/i18n';
import { langCookie } from './storage/lang-cookie.server';
export const streamTimeout = 5_000;
export default async function handleRequest(
@ -17,12 +22,13 @@ export default async function handleRequest(
routerContext: EntryContext,
_loadContext: AppLoadContext,
) {
// Todo: i18n
const locale = 'en';
// const { messages } = await import(`../../../packages/lib/translations/en/web.po`);
// const { messages } = await import(`../../../packages/lib/translations/${locale}/web.po`);
let language = await langCookie.parse(request.headers.get('cookie') ?? '');
i18n.loadAndActivate({ locale, messages: {} });
if (!APP_I18N_OPTIONS.supportedLangs.includes(language)) {
language = extractLocaleData({ headers: request.headers }).lang;
}
await dynamicActivate(language);
return new Promise((resolve, reject) => {
let shellRendered = false;