diff --git a/app/components/chat/Chat.client.tsx b/app/components/chat/Chat.client.tsx index dff7598e4..4f48fcc9c 100644 --- a/app/components/chat/Chat.client.tsx +++ b/app/components/chat/Chat.client.tsx @@ -12,6 +12,7 @@ import { fileModificationsToHTML } from '~/utils/diff'; import { cubicEasingFn } from '~/utils/easings'; import { createScopedLogger, renderLogger } from '~/utils/logger'; import { BaseChat } from './BaseChat'; +import { useTranslation } from 'react-i18next'; const toastAnimation = cssTransition({ enter: 'animated fadeInRight', @@ -75,11 +76,13 @@ export const ChatImpl = memo(({ initialMessages, storeMessageHistory }: ChatProp const [animationScope, animate] = useAnimate(); + const { t } = useTranslation(); + const { messages, isLoading, input, handleInputChange, setInput, stop, append } = useChat({ api: '/api/chat', onError: (error) => { logger.error('Request failed\n\n', error); - toast.error('There was an error processing your request'); + toast.error(t('toast.error.generic')); }, onFinish: () => { logger.debug('Finished streaming'); diff --git a/app/components/sidebar/Menu.client.tsx b/app/components/sidebar/Menu.client.tsx index a16ce299d..290d7888d 100644 --- a/app/components/sidebar/Menu.client.tsx +++ b/app/components/sidebar/Menu.client.tsx @@ -64,7 +64,7 @@ export function Menu() { } }) .catch((error) => { - toast.error('Failed to delete conversation'); + toast.error(t('toast.error.failedToDeleteConversation')); logger.error(error); }); } diff --git a/app/components/workbench/Workbench.client.tsx b/app/components/workbench/Workbench.client.tsx index 87733b4c3..4d8275344 100644 --- a/app/components/workbench/Workbench.client.tsx +++ b/app/components/workbench/Workbench.client.tsx @@ -92,7 +92,7 @@ export const Workbench = memo(({ chatStarted, isStreaming }: WorkspaceProps) => const onFileSave = useCallback(() => { workbenchStore.saveCurrentDocument().catch(() => { - toast.error('Failed to update file content'); + toast.error(t('toast.error.failedToUpdateFileContent')); }); }, []); diff --git a/app/lib/persistence/useChatHistory.ts b/app/lib/persistence/useChatHistory.ts index e56275327..6ff60f50c 100644 --- a/app/lib/persistence/useChatHistory.ts +++ b/app/lib/persistence/useChatHistory.ts @@ -5,7 +5,7 @@ import type { Message } from 'ai'; import { toast } from 'react-toastify'; import { workbenchStore } from '~/lib/stores/workbench'; import { getMessages, getNextId, getUrlId, openDatabase, setMessages } from './db'; - +import { useTranslation } from 'react-i18next'; export interface ChatHistoryItem { id: string; urlId?: string; @@ -28,13 +28,14 @@ export function useChatHistory() { const [initialMessages, setInitialMessages] = useState([]); const [ready, setReady] = useState(false); const [urlId, setUrlId] = useState(); + const { t } = useTranslation(); useEffect(() => { if (!db) { setReady(true); if (persistenceEnabled) { - toast.error(`Chat persistence is unavailable`); + toast.error(t('toast.error.chatPersistenceUnavailable')); } return; diff --git a/public/locales/ca/translation.json b/public/locales/ca/translation.json index ba96690bb..6847fcb74 100644 --- a/public/locales/ca/translation.json +++ b/public/locales/ca/translation.json @@ -47,5 +47,13 @@ "spaceInvaders": "Crea un joc d'Space Invaders", "centerDiv": "Com centro un div?" } + }, + "toast": { + "error": { + "generic": "S'ha produït un error", + "failedToDeleteConversation": "No s'ha pogut eliminar la conversa", + "failedToUpdateFileContent": "No s'ha pogut actualitzar el contingut del fitxer", + "chatPersistenceUnavailable": "La persistència del xat no està disponible" + } } } \ No newline at end of file diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index f59ff0cce..3c68ca855 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -47,5 +47,13 @@ "spaceInvaders": "Make a space invaders game", "centerDiv": "How do I center a div?" } + }, + "toast": { + "error": { + "generic": "There was an error processing your request", + "failedToDeleteConversation": "Failed to delete conversation", + "failedToUpdateFileContent": "Failed to update file content", + "chatPersistenceUnavailable": "Chat persistence is unavailable" + } } } \ No newline at end of file diff --git a/public/locales/es/translation.json b/public/locales/es/translation.json index d38b572e5..39daf9903 100644 --- a/public/locales/es/translation.json +++ b/public/locales/es/translation.json @@ -46,5 +46,13 @@ "spaceInvaders": "Crea un juego como Space Invaders", "centerDiv": "¿Cómo centro un div?" } + }, + "toast": { + "error": { + "generic": "Se produjo un error", + "failedToDeleteConversation": "No se pudo eliminar la conversación", + "failedToUpdateFileContent": "No se pudo actualizar el contenido del archivo", + "chatPersistenceUnavailable": "La persistencia del chat no está disponible" + } } -} \ No newline at end of file +}