feat: web i18n (#1286)

This commit is contained in:
David Nguyen
2024-08-27 20:34:39 +09:00
committed by GitHub
parent 0829311214
commit 75c8772a02
294 changed files with 14846 additions and 2229 deletions

View File

@ -2,6 +2,9 @@
import Link from 'next/link';
import type { MessageDescriptor } from '@lingui/core';
import { Trans, msg } from '@lingui/macro';
import { useLingui } from '@lingui/react';
import { motion } from 'framer-motion';
import { AlertTriangle, Plus } from 'lucide-react';
import { useDropzone } from 'react-dropzone';
@ -25,7 +28,7 @@ import { Card, CardContent } from './card';
export type DocumentDropzoneProps = {
className?: string;
disabled?: boolean;
disabledMessage?: string;
disabledMessage?: MessageDescriptor;
onDrop?: (_file: File) => void | Promise<void>;
onDropRejected?: () => void | Promise<void>;
type?: 'document' | 'template';
@ -37,10 +40,12 @@ export const DocumentDropzone = ({
onDrop,
onDropRejected,
disabled,
disabledMessage = 'You cannot upload documents at this time.',
disabledMessage = msg`You cannot upload documents at this time.`,
type = 'document',
...props
}: DocumentDropzoneProps) => {
const { _ } = useLingui();
const { getRootProps, getInputProps } = useDropzone({
accept: {
'application/pdf': ['.pdf'],
@ -61,8 +66,8 @@ export const DocumentDropzone = ({
});
const heading = {
document: disabled ? 'You have reached your document limit.' : 'Add a document',
template: 'Upload Template Document',
document: disabled ? msg`You have reached your document limit.` : msg`Add a document`,
template: msg`Upload Template Document`,
};
return (
@ -151,15 +156,17 @@ export const DocumentDropzone = ({
<input {...getInputProps()} />
<p className="text-foreground mt-8 font-medium">{heading[type]}</p>
<p className="text-foreground mt-8 font-medium">{_(heading[type])}</p>
<p className="text-muted-foreground/80 mt-1 text-center text-sm">
{disabled ? disabledMessage : 'Drag & drop your PDF here.'}
{_(disabled ? disabledMessage : msg`Drag & drop your PDF here.`)}
</p>
{disabled && IS_BILLING_ENABLED() && (
<Button className="hover:bg-warning/80 bg-warning mt-4 w-32" asChild>
<Link href="/settings/billing">Upgrade</Link>
<Link href="/settings/billing">
<Trans>Upgrade</Trans>
</Link>
</Button>
)}
</CardContent>