mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-05-03 22:37:28 +08:00
fix webui i18n
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import { AnimatePresence, motion } from 'motion/react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
type DialogOptions = {
|
||||
title?: string;
|
||||
@@ -16,6 +17,7 @@ export const GlobalDialog: React.FC<{
|
||||
onConfirm: () => void;
|
||||
onCancel: () => void;
|
||||
}> = ({ open, kind, options, onConfirm, onCancel }) => {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{open && (
|
||||
@@ -24,15 +26,15 @@ export const GlobalDialog: React.FC<{
|
||||
<motion.div className="w-full max-w-md rounded-2xl border border-zinc-700 bg-zinc-900 shadow-2xl"
|
||||
initial={{ scale: 0.95, y: 8 }} animate={{ scale: 1, y: 0 }} exit={{ scale: 0.95, y: 8 }}>
|
||||
<div className="px-5 py-4 border-b border-zinc-800">
|
||||
<h3 className="text-sm font-semibold text-zinc-100">{options.title || (kind === 'confirm' ? 'Please confirm' : 'Notice')}</h3>
|
||||
<h3 className="text-sm font-semibold text-zinc-100">{options.title || (kind === 'confirm' ? t('dialogPleaseConfirm') : t('dialogNotice'))}</h3>
|
||||
</div>
|
||||
<div className="px-5 py-4 text-sm text-zinc-300 whitespace-pre-wrap">{options.message}</div>
|
||||
<div className="px-5 pb-5 flex items-center justify-end gap-2">
|
||||
{kind === 'confirm' && (
|
||||
<button onClick={onCancel} className="px-3 py-1.5 rounded-lg bg-zinc-800 hover:bg-zinc-700 text-zinc-200 text-sm">{options.cancelText || 'Cancel'}</button>
|
||||
<button onClick={onCancel} className="px-3 py-1.5 rounded-lg bg-zinc-800 hover:bg-zinc-700 text-zinc-200 text-sm">{options.cancelText || t('cancel')}</button>
|
||||
)}
|
||||
<button onClick={onConfirm} className={`px-3 py-1.5 rounded-lg text-sm ${options.danger ? 'bg-red-600 hover:bg-red-500 text-white' : 'bg-indigo-600 hover:bg-indigo-500 text-white'}`}>
|
||||
{options.confirmText || 'OK'}
|
||||
{options.confirmText || t('dialogOk')}
|
||||
</button>
|
||||
</div>
|
||||
</motion.div>
|
||||
|
||||
@@ -21,7 +21,7 @@ const Header: React.FC = () => {
|
||||
<div className="w-8 h-8 md:w-9 md:h-9 rounded-xl bg-indigo-500 flex items-center justify-center shadow-lg shadow-indigo-500/20 shrink-0">
|
||||
<Terminal className="w-4 h-4 md:w-5 md:h-5 text-white" />
|
||||
</div>
|
||||
<span className="hidden md:inline font-semibold text-lg md:text-xl tracking-tight truncate">ClawGo</span>
|
||||
<span className="hidden md:inline font-semibold text-lg md:text-xl tracking-tight truncate">{t('appName')}</span>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2 md:gap-6">
|
||||
|
||||
@@ -25,6 +25,7 @@ const PrimitiveArrayEditor: React.FC<{
|
||||
path: string;
|
||||
onChange: (next: any[]) => void;
|
||||
}> = ({ value, path, onChange }) => {
|
||||
const { t } = useTranslation();
|
||||
const [draft, setDraft] = useState('');
|
||||
const [selected, setSelected] = useState('');
|
||||
|
||||
@@ -54,7 +55,7 @@ const PrimitiveArrayEditor: React.FC<{
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{value.length === 0 && <span className="text-xs text-zinc-500 italic">(empty)</span>}
|
||||
{value.length === 0 && <span className="text-xs text-zinc-500 italic">{t('empty')}</span>}
|
||||
{value.map((item, idx) => (
|
||||
<span key={`${item}-${idx}`} className="inline-flex items-center gap-1 px-2 py-1 rounded bg-zinc-900 border border-zinc-700 text-xs font-mono text-zinc-200">
|
||||
{String(item)}
|
||||
@@ -68,7 +69,7 @@ const PrimitiveArrayEditor: React.FC<{
|
||||
list={`${path}-suggestions`}
|
||||
value={draft}
|
||||
onChange={(e) => setDraft(e.target.value)}
|
||||
placeholder="输入新值后添加"
|
||||
placeholder={t('recursiveAddValuePlaceholder')}
|
||||
className="w-full bg-zinc-950 border border-zinc-800 rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-indigo-500"
|
||||
/>
|
||||
<datalist id={`${path}-suggestions`}>
|
||||
@@ -84,7 +85,7 @@ const PrimitiveArrayEditor: React.FC<{
|
||||
}}
|
||||
className="px-3 py-2 text-xs rounded-lg bg-zinc-800 hover:bg-zinc-700"
|
||||
>
|
||||
添加
|
||||
{t('add')}
|
||||
</button>
|
||||
|
||||
<select
|
||||
@@ -96,7 +97,7 @@ const PrimitiveArrayEditor: React.FC<{
|
||||
}}
|
||||
className="px-3 py-2 text-xs rounded-lg bg-zinc-950 border border-zinc-800"
|
||||
>
|
||||
<option value="">下拉选择</option>
|
||||
<option value="">{t('recursiveSelectOption')}</option>
|
||||
{suggestions.filter((s) => !value.includes(s)).map((s) => (
|
||||
<option key={s} value={s}>{s}</option>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user