fix: resolve internal pdf translations
This commit is contained in:
@@ -9,7 +9,7 @@ import { RECIPIENT_ROLES_DESCRIPTION } from '@documenso/lib/constants/recipient-
|
|||||||
import { getEntireDocument } from '@documenso/lib/server-only/admin/get-entire-document';
|
import { getEntireDocument } from '@documenso/lib/server-only/admin/get-entire-document';
|
||||||
import { decryptSecondaryData } from '@documenso/lib/server-only/crypto/decrypt';
|
import { decryptSecondaryData } from '@documenso/lib/server-only/crypto/decrypt';
|
||||||
import { findDocumentAuditLogs } from '@documenso/lib/server-only/document/find-document-audit-logs';
|
import { findDocumentAuditLogs } from '@documenso/lib/server-only/document/find-document-audit-logs';
|
||||||
import { dynamicActivate } from '@documenso/lib/utils/i18n';
|
import { getTranslations } from '@documenso/lib/utils/i18n';
|
||||||
import { Card, CardContent } from '@documenso/ui/primitives/card';
|
import { Card, CardContent } from '@documenso/ui/primitives/card';
|
||||||
|
|
||||||
import { BrandingLogo } from '~/components/general/branding-logo';
|
import { BrandingLogo } from '~/components/general/branding-logo';
|
||||||
@@ -49,10 +49,13 @@ export async function loader({ request }: Route.LoaderArgs) {
|
|||||||
perPage: 100_000,
|
perPage: 100_000,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const messages = await getTranslations(documentLanguage);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
auditLogs,
|
auditLogs,
|
||||||
document,
|
document,
|
||||||
documentLanguage,
|
documentLanguage,
|
||||||
|
messages,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,16 +64,15 @@ export async function loader({ request }: Route.LoaderArgs) {
|
|||||||
*
|
*
|
||||||
* Cannot use dynamicActivate by itself to translate this specific page and all
|
* Cannot use dynamicActivate by itself to translate this specific page and all
|
||||||
* children components because `not-found.tsx` page runs and overrides the i18n.
|
* children components because `not-found.tsx` page runs and overrides the i18n.
|
||||||
|
*
|
||||||
|
* Update: Maybe <Trans> tags work now after RR7 migration.
|
||||||
*/
|
*/
|
||||||
export default function AuditLog({ loaderData }: Route.ComponentProps) {
|
export default function AuditLog({ loaderData }: Route.ComponentProps) {
|
||||||
const { auditLogs, document, documentLanguage } = loaderData;
|
const { auditLogs, document, documentLanguage, messages } = loaderData;
|
||||||
|
|
||||||
const { i18n } = useLingui();
|
const { i18n, _ } = useLingui();
|
||||||
|
|
||||||
// Todo
|
i18n.loadAndActivate({ locale: documentLanguage, messages });
|
||||||
void dynamicActivate(documentLanguage);
|
|
||||||
|
|
||||||
const { _ } = useLingui();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="print-provider pointer-events-none mx-auto max-w-screen-md">
|
<div className="print-provider pointer-events-none mx-auto max-w-screen-md">
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import { decryptSecondaryData } from '@documenso/lib/server-only/crypto/decrypt'
|
|||||||
import { getDocumentCertificateAuditLogs } from '@documenso/lib/server-only/document/get-document-certificate-audit-logs';
|
import { getDocumentCertificateAuditLogs } from '@documenso/lib/server-only/document/get-document-certificate-audit-logs';
|
||||||
import { DOCUMENT_AUDIT_LOG_TYPE } from '@documenso/lib/types/document-audit-logs';
|
import { DOCUMENT_AUDIT_LOG_TYPE } from '@documenso/lib/types/document-audit-logs';
|
||||||
import { extractDocumentAuthMethods } from '@documenso/lib/utils/document-auth';
|
import { extractDocumentAuthMethods } from '@documenso/lib/utils/document-auth';
|
||||||
|
import { getTranslations } from '@documenso/lib/utils/i18n';
|
||||||
import { Card, CardContent } from '@documenso/ui/primitives/card';
|
import { Card, CardContent } from '@documenso/ui/primitives/card';
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
@@ -64,10 +65,13 @@ export async function loader({ request }: Route.LoaderArgs) {
|
|||||||
id: documentId,
|
id: documentId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const messages = await getTranslations(documentLanguage);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
document,
|
document,
|
||||||
documentLanguage,
|
documentLanguage,
|
||||||
auditLogs,
|
auditLogs,
|
||||||
|
messages,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,16 +81,15 @@ export async function loader({ request }: Route.LoaderArgs) {
|
|||||||
*
|
*
|
||||||
* Cannot use dynamicActivate by itself to translate this specific page and all
|
* Cannot use dynamicActivate by itself to translate this specific page and all
|
||||||
* children components because `not-found.tsx` page runs and overrides the i18n.
|
* children components because `not-found.tsx` page runs and overrides the i18n.
|
||||||
|
*
|
||||||
|
* Update: Maybe <Trans> tags work now after RR7 migration.
|
||||||
*/
|
*/
|
||||||
export default function SigningCertificate({ loaderData }: Route.ComponentProps) {
|
export default function SigningCertificate({ loaderData }: Route.ComponentProps) {
|
||||||
const { document, documentLanguage, auditLogs } = loaderData;
|
const { document, documentLanguage, auditLogs, messages } = loaderData;
|
||||||
|
|
||||||
const { i18n } = useLingui();
|
const { i18n, _ } = useLingui();
|
||||||
|
|
||||||
const { _ } = useLingui();
|
i18n.loadAndActivate({ locale: documentLanguage, messages });
|
||||||
|
|
||||||
// Todo
|
|
||||||
// dynamicActivate(i18n, documentLanguage);
|
|
||||||
|
|
||||||
const isOwner = (email: string) => {
|
const isOwner = (email: string) => {
|
||||||
return email.toLowerCase() === document.user.email.toLowerCase();
|
return email.toLowerCase() === document.user.email.toLowerCase();
|
||||||
|
|||||||
@@ -5,11 +5,17 @@ import type { I18nLocaleData, SupportedLanguageCodes } from '../constants/i18n';
|
|||||||
import { APP_I18N_OPTIONS } from '../constants/i18n';
|
import { APP_I18N_OPTIONS } from '../constants/i18n';
|
||||||
import { env } from './env';
|
import { env } from './env';
|
||||||
|
|
||||||
export async function dynamicActivate(locale: string) {
|
export async function getTranslations(locale: string) {
|
||||||
const extension = env('NODE_ENV') === 'development' ? 'po' : 'mjs';
|
const extension = env('NODE_ENV') === 'development' ? 'po' : 'mjs';
|
||||||
|
|
||||||
const { messages } = await import(`../translations/${locale}/web.${extension}`);
|
const { messages } = await import(`../translations/${locale}/web.${extension}`);
|
||||||
|
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function dynamicActivate(locale: string) {
|
||||||
|
const messages = await getTranslations(locale);
|
||||||
|
|
||||||
i18n.loadAndActivate({ locale, messages });
|
i18n.loadAndActivate({ locale, messages });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user