mirror of
https://github.com/stackblitz/bolt.new
synced 2025-06-26 18:17:50 +00:00
feat: localize error messages
This commit is contained in:
parent
ee0be3b605
commit
59093f1ad6
@ -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');
|
||||
|
||||
@ -64,7 +64,7 @@ export function Menu() {
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
toast.error('Failed to delete conversation');
|
||||
toast.error(t('toast.error.failedToDeleteConversation'));
|
||||
logger.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
@ -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'));
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
||||
@ -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<Message[]>([]);
|
||||
const [ready, setReady] = useState<boolean>(false);
|
||||
const [urlId, setUrlId] = useState<string | undefined>();
|
||||
const { t } = useTranslation();
|
||||
|
||||
useEffect(() => {
|
||||
if (!db) {
|
||||
setReady(true);
|
||||
|
||||
if (persistenceEnabled) {
|
||||
toast.error(`Chat persistence is unavailable`);
|
||||
toast.error(t('toast.error.chatPersistenceUnavailable'));
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user