From 3b116a2b215da8e8f52cc8ad32d17f90f185a340 Mon Sep 17 00:00:00 2001 From: Felix NyxJae <52313587+NyxJae@users.noreply.github.com> Date: Tue, 18 Mar 2025 21:36:48 +0800 Subject: [PATCH] I18n human relay (#1761) * feat(i18n): Add i18n support for Human Relay dialog without monitoring * feat(i18n): add humanRelay.json translations for all supported languages - Created English version as base translation - Added translations for: ca, de, es, fr, hi, it, ja, ko, pl, pt-BR, tr, vi, zh-TW - Verified all translations are complete with no missing entries --- .../human-relay/HumanRelayDialog.tsx | 28 ++++++++++--------- .../src/i18n/locales/ca/humanRelay.json | 13 +++++++++ .../src/i18n/locales/de/humanRelay.json | 13 +++++++++ .../src/i18n/locales/en/humanRelay.json | 13 +++++++++ .../src/i18n/locales/es/humanRelay.json | 13 +++++++++ .../src/i18n/locales/fr/humanRelay.json | 13 +++++++++ .../src/i18n/locales/hi/humanRelay.json | 13 +++++++++ .../src/i18n/locales/it/humanRelay.json | 13 +++++++++ .../src/i18n/locales/ja/humanRelay.json | 13 +++++++++ .../src/i18n/locales/ko/humanRelay.json | 13 +++++++++ .../src/i18n/locales/pl/humanRelay.json | 13 +++++++++ .../src/i18n/locales/pt-BR/humanRelay.json | 13 +++++++++ .../src/i18n/locales/tr/humanRelay.json | 13 +++++++++ .../src/i18n/locales/vi/humanRelay.json | 13 +++++++++ .../src/i18n/locales/zh-CN/humanRelay.json | 13 +++++++++ .../src/i18n/locales/zh-TW/humanRelay.json | 13 +++++++++ 16 files changed, 210 insertions(+), 13 deletions(-) create mode 100644 webview-ui/src/i18n/locales/ca/humanRelay.json create mode 100644 webview-ui/src/i18n/locales/de/humanRelay.json create mode 100644 webview-ui/src/i18n/locales/en/humanRelay.json create mode 100644 webview-ui/src/i18n/locales/es/humanRelay.json create mode 100644 webview-ui/src/i18n/locales/fr/humanRelay.json create mode 100644 webview-ui/src/i18n/locales/hi/humanRelay.json create mode 100644 webview-ui/src/i18n/locales/it/humanRelay.json create mode 100644 webview-ui/src/i18n/locales/ja/humanRelay.json create mode 100644 webview-ui/src/i18n/locales/ko/humanRelay.json create mode 100644 webview-ui/src/i18n/locales/pl/humanRelay.json create mode 100644 webview-ui/src/i18n/locales/pt-BR/humanRelay.json create mode 100644 webview-ui/src/i18n/locales/tr/humanRelay.json create mode 100644 webview-ui/src/i18n/locales/vi/humanRelay.json create mode 100644 webview-ui/src/i18n/locales/zh-CN/humanRelay.json create mode 100644 webview-ui/src/i18n/locales/zh-TW/humanRelay.json diff --git a/webview-ui/src/components/human-relay/HumanRelayDialog.tsx b/webview-ui/src/components/human-relay/HumanRelayDialog.tsx index 61d4cbe213..87af4832c6 100644 --- a/webview-ui/src/components/human-relay/HumanRelayDialog.tsx +++ b/webview-ui/src/components/human-relay/HumanRelayDialog.tsx @@ -4,6 +4,7 @@ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, D import { Textarea } from "../ui/textarea" import { useClipboard } from "../ui/hooks" import { Check, Copy, X } from "lucide-react" +import { useAppTranslation } from "@/i18n/TranslationContext" interface HumanRelayDialogProps { isOpen: boolean @@ -26,11 +27,12 @@ export const HumanRelayDialog: React.FC = ({ onSubmit, onCancel, }) => { + const { t } = useAppTranslation() const [response, setResponse] = React.useState("") const { copy } = useClipboard() const [isCopyClicked, setIsCopyClicked] = React.useState(false) - // Listen to isOpen changes, clear the input box when the dialog box is opened + // Clear input when dialog opens React.useEffect(() => { if (isOpen) { setResponse("") @@ -38,7 +40,7 @@ export const HumanRelayDialog: React.FC = ({ } }, [isOpen]) - // Copy to clipboard and show a success message + // Copy to clipboard and show success message const handleCopy = () => { copy(promptText) setIsCopyClicked(true) @@ -47,7 +49,7 @@ export const HumanRelayDialog: React.FC = ({ }, 2000) } - // Submit the response + // Submit response const handleSubmit = (e: React.FormEvent) => { e.preventDefault() if (response.trim()) { @@ -56,7 +58,7 @@ export const HumanRelayDialog: React.FC = ({ } } - // Cancel the operation + // Cancel operation const handleCancel = () => { onCancel(requestId) onClose() @@ -66,10 +68,8 @@ export const HumanRelayDialog: React.FC = ({ !open && handleCancel()}> - Human Relay - Please Help Copy and Paste Information - - Please copy the text below to the web AI, then paste the AI's response into the input box below. - + {t("humanRelay:dialogTitle")} + {t("humanRelay:dialogDescription")}
@@ -84,12 +84,14 @@ export const HumanRelayDialog: React.FC = ({
- {isCopyClicked &&
Copied to clipboard
} + {isCopyClicked && ( +
{t("humanRelay:copiedToClipboard")}
+ )}
-
Please enter the AI's response:
+
{t("humanRelay:aiResponse.label")}