mirror of
https://github.com/documenso/documenso.git
synced 2025-11-13 08:13:56 +10:00
feat: improve translation coverage (#1427)
Improves translation coverage across the app.
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
import { useLingui } from '@lingui/react';
|
||||
import { AnimatePresence, motion } from 'framer-motion';
|
||||
|
||||
import { cn } from '../../lib/utils';
|
||||
@ -12,6 +13,15 @@ const isErrorWithMessage = (error: unknown): error is { message?: string } => {
|
||||
};
|
||||
|
||||
export const FormErrorMessage = ({ error, className }: FormErrorMessageProps) => {
|
||||
const { i18n } = useLingui();
|
||||
|
||||
let errorMessage = isErrorWithMessage(error) ? error.message : '';
|
||||
|
||||
// Checks to see if there's a translation for the string, since we're passing IDs for Zod errors.
|
||||
if (typeof errorMessage === 'string' && i18n.t(errorMessage)) {
|
||||
errorMessage = i18n.t(errorMessage);
|
||||
}
|
||||
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{isErrorWithMessage(error) && (
|
||||
@ -30,7 +40,7 @@ export const FormErrorMessage = ({ error, className }: FormErrorMessageProps) =>
|
||||
}}
|
||||
className={cn('text-xs text-red-500', className)}
|
||||
>
|
||||
{error.message}
|
||||
{errorMessage}
|
||||
</motion.p>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
|
||||
Reference in New Issue
Block a user