Skip to content

DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.

fix(quiz): translate follow-up notebook writeback errors

Bingxi Zhao (Frank)33c81a435c06
diff --git a/web/context/QuizFollowupContext.tsx b/web/context/QuizFollowupContext.tsx
index ee433fa9c..8709925a3 100644
--- a/web/context/QuizFollowupContext.tsx
+++ b/web/context/QuizFollowupContext.tsx
@@ -26,6 +26,7 @@ import {
useRef,
useState,
} from "react";
+import { useTranslation } from "react-i18next";
import { updateNotebookEntry } from "@/lib/notebook-api";
import { shouldAppendEventContent } from "@/lib/stream";
import { hasPendingAskUser } from "@/lib/ask-user-state";
@@ -220,6 +221,7 @@ interface ProviderProps {
}
export function QuizFollowupProvider({ children }: ProviderProps) {
+ const { t } = useTranslation();
const [threads, setThreads] = useState<Record<string, FollowupThreadState>>(
{},
);
@@ -275,13 +277,13 @@ export function QuizFollowupProvider({ children }: ProviderProps) {
...prev,
error:
prev.error ||
- "Failed to link this follow-up chat to its notebook entry.",
+ t("Failed to link this follow-up chat to its notebook entry."),
}));
}
}
})();
},
- [updateThread],
+ [t, updateThread],
);
const handleThreadEvent = useCallback(
diff --git a/web/locales/de/app.json b/web/locales/de/app.json
index 3f7df7d41..f694035cb 100644
--- a/web/locales/de/app.json
+++ b/web/locales/de/app.json
@@ -5333,5 +5333,6 @@
"Speech was generated, but the audio download failed. Try again or check the network connection.": "Die Sprache wurde erzeugt, aber der Audiodownload ist fehlgeschlagen. Versuche es erneut oder prüfe die Netzwerkverbindung.",
"Request timeout (seconds)": "Zeitlimit für Anfragen (Sekunden)",
"Show API token": "API-Token anzeigen",
- "Hide API token": "API-Token ausblenden"
+ "Hide API token": "API-Token ausblenden",
+ "Failed to link this follow-up chat to its notebook entry.": "Dieser Folgechat konnte nicht mit seinem Notizbucheintrag verknüpft werden."
}
diff --git a/web/locales/en/app.json b/web/locales/en/app.json
index d0c7bd50d..f756131fa 100644
--- a/web/locales/en/app.json
+++ b/web/locales/en/app.json
@@ -5333,5 +5333,6 @@
"Speech was generated, but the audio download failed. Try again or check the network connection.": "Speech was generated, but the audio download failed. Try again or check the network connection.",
"Request timeout (seconds)": "Request timeout (seconds)",
"Show API token": "Show API token",
- "Hide API token": "Hide API token"
+ "Hide API token": "Hide API token",
+ "Failed to link this follow-up chat to its notebook entry.": "Failed to link this follow-up chat to its notebook entry."
}
diff --git a/web/locales/fr/app.json b/web/locales/fr/app.json
index c8c6de687..adcf607be 100644
--- a/web/locales/fr/app.json
+++ b/web/locales/fr/app.json
@@ -5776,5 +5776,6 @@
"Qwen-Audio TTS requires a Beijing API key. You can set a Beijing workspace URL in the provider connection; the speech endpoint is selected automatically.": "Qwen-Audio TTS nécessite une clé API pour la région de Pékin. Vous pouvez définir une URL d’espace de travail de Pékin dans la connexion au fournisseur ; le point de terminaison vocal est sélectionné automatiquement.",
"Fetching the model list does not test speech synthesis. Use Preview voice to test this model and voice.": "Récupérer la liste des modèles ne teste pas la synthèse vocale. Utilisez l’aperçu vocal pour tester ce modèle et cette voix.",
"Show API token": "Afficher le jeton API",
- "Hide API token": "Masquer le jeton API"
+ "Hide API token": "Masquer le jeton API",
+ "Failed to link this follow-up chat to its notebook entry.": "Impossible de lier cette conversation de suivi à son entrée dans le carnet."
}
diff --git a/web/locales/pl/app.json b/web/locales/pl/app.json
index 97bacb07e..5d9d6b3a2 100644
--- a/web/locales/pl/app.json
+++ b/web/locales/pl/app.json
@@ -5349,5 +5349,6 @@
"Qwen-Audio TTS requires a Beijing API key. You can set a Beijing workspace URL in the provider connection; the speech endpoint is selected automatically.": "Qwen-Audio TTS wymaga klucza API z regionu Pekin. W połączeniu z dostawcą możesz ustawić adres URL przestrzeni roboczej z regionu Pekin; punkt końcowy mowy zostanie wybrany automatycznie.",
"Fetching the model list does not test speech synthesis. Use Preview voice to test this model and voice.": "Pobranie listy modeli nie sprawdza syntezy mowy. Użyj podglądu głosu, aby przetestować model i głos.",
"Show API token": "Pokaż token API",
- "Hide API token": "Ukryj token API"
+ "Hide API token": "Ukryj token API",
+ "Failed to link this follow-up chat to its notebook entry.": "Nie udało się powiązać tej rozmowy uzupełniającej z wpisem w notatniku."
}
diff --git a/web/locales/uk/app.json b/web/locales/uk/app.json
index 99cc700fd..5619c8038 100644
--- a/web/locales/uk/app.json
+++ b/web/locales/uk/app.json
@@ -5349,5 +5349,6 @@
"Qwen-Audio TTS requires a Beijing API key. You can set a Beijing workspace URL in the provider connection; the speech endpoint is selected automatically.": "Qwen-Audio TTS потребує ключа API для регіону Пекін. У підключенні провайдера можна задати URL робочого простору для регіону Пекін; кінцева точка мовлення вибирається автоматично.",
"Fetching the model list does not test speech synthesis. Use Preview voice to test this model and voice.": "Отримання списку моделей не перевіряє синтез мовлення. Скористайтеся попереднім прослуховуванням голосу, щоб перевірити модель і голос.",
"Show API token": "Показати токен API",
- "Hide API token": "Приховати токен API"
+ "Hide API token": "Приховати токен API",
+ "Failed to link this follow-up chat to its notebook entry.": "Не вдалося пов’язати цей додатковий чат із відповідним записом у нотатнику."
}
diff --git a/web/locales/zh/app.json b/web/locales/zh/app.json
index 115686cd8..df2bc4b3e 100644
--- a/web/locales/zh/app.json
+++ b/web/locales/zh/app.json
@@ -5333,5 +5333,6 @@
"Speech was generated, but the audio download failed. Try again or check the network connection.": "语音已生成,但音频下载失败,请重试或检查网络连接。",
"Request timeout (seconds)": "请求超时(秒)",
"Show API token": "显示 API 令牌",
- "Hide API token": "隐藏 API 令牌"
+ "Hide API token": "隐藏 API 令牌",
+ "Failed to link this follow-up chat to its notebook entry.": "无法将此追问对话关联到对应的笔记条目。"
}
diff --git a/web/tests/quiz-followup-writeback.spec.tsx b/web/tests/quiz-followup-writeback.spec.tsx
index e3299bd6c..f9c2bc1b5 100644
--- a/web/tests/quiz-followup-writeback.spec.tsx
+++ b/web/tests/quiz-followup-writeback.spec.tsx
@@ -9,6 +9,12 @@ import {
import { updateNotebookEntry } from "@/lib/notebook-api";
import type { QuizQuestion } from "@/lib/quiz-types";
+const translations = vi.hoisted(() => ({
+ t: vi.fn((key: string) => key === "Failed to link this follow-up chat to its notebook entry."
+ ? "无法关联笔记条目" : key),
+}));
+vi.mock("react-i18next", () => ({ useTranslation: () => translations }));
+
const clientInstances = vi.hoisted(
() =>
[] as Array<{
@@ -140,7 +146,7 @@ it("surfaces a visible error when the session-id writeback keeps failing", async
renderFollowup();
emitSessionEvent();
expect(await screen.findByRole("alert")).toHaveTextContent(
- /notebook entry/i,
+ "无法关联笔记条目",
);
expect(updateNotebookEntry).toHaveBeenCalledTimes(2);
expect(updateNotebookEntry).toHaveBeenCalledWith(ENTRY_ID, {