diff --git a/app/generation-preview/page.tsx b/app/generation-preview/page.tsx index b63b4eb69..936cfe5c6 100644 --- a/app/generation-preview/page.tsx +++ b/app/generation-preview/page.tsx @@ -278,15 +278,11 @@ function GenerationPreviewContent() { // Truncation warnings const warnings: string[] = []; if ((parseResult.data.text as string).length > MAX_PDF_CONTENT_CHARS) { - warnings.push( - t('generation.textTruncated').replace('{n}', String(MAX_PDF_CONTENT_CHARS)), - ); + warnings.push(t('generation.textTruncated', { n: MAX_PDF_CONTENT_CHARS })); } if (images.length > MAX_VISION_IMAGES) { warnings.push( - t('generation.imageTruncated') - .replace('{total}', String(images.length)) - .replace('{max}', String(MAX_VISION_IMAGES)), + t('generation.imageTruncated', { total: images.length, max: MAX_VISION_IMAGES }), ); } if (warnings.length > 0) { diff --git a/app/page.tsx b/app/page.tsx index c0da47614..1799ea97e 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -20,6 +20,7 @@ import { ChevronUp, } from 'lucide-react'; import { useI18n } from '@/lib/hooks/use-i18n'; +import { LanguageSwitcher } from '@/components/language-switcher'; import { createLogger } from '@/lib/logger'; import { Button } from '@/components/ui/button'; import { Textarea as UITextarea } from '@/components/ui/textarea'; @@ -69,7 +70,7 @@ const initialFormState: FormState = { }; function HomePage() { - const { t, locale, setLocale } = useI18n(); + const { t } = useI18n(); const { theme, setTheme } = useTheme(); const router = useRouter(); const [form, setForm] = useState(initialFormState); @@ -124,7 +125,6 @@ function HomePage() { } } - const [languageOpen, setLanguageOpen] = useState(false); const [themeOpen, setThemeOpen] = useState(false); const [error, setError] = useState(null); const [classrooms, setClassrooms] = useState([]); @@ -135,16 +135,15 @@ function HomePage() { // Close dropdowns when clicking outside useEffect(() => { - if (!languageOpen && !themeOpen) return; + if (!themeOpen) return; const handleClickOutside = (e: MouseEvent) => { if (toolbarRef.current && !toolbarRef.current.contains(e.target as Node)) { - setLanguageOpen(false); setThemeOpen(false); } }; document.addEventListener('mousedown', handleClickOutside); return () => document.removeEventListener('mousedown', handleClickOutside); - }, [languageOpen, themeOpen]); + }, [themeOpen]); const loadClassrooms = async () => { try { @@ -338,47 +337,7 @@ function HomePage() { className="fixed top-4 right-4 z-50 flex items-center gap-1 bg-white/60 dark:bg-gray-800/60 backdrop-blur-md px-2 py-1.5 rounded-full border border-gray-100/50 dark:border-gray-700/50 shadow-sm" > {/* Language Selector */} -
- - {languageOpen && ( -
- - -
- )} -
+ setThemeOpen(false)} />
@@ -387,7 +346,6 @@ function HomePage() { - {languageOpen && ( -
- - -
- )} -
+ setThemeOpen(false)} />
@@ -149,7 +105,6 @@ export function Header({ currentSceneTitle }: HeaderProps) { + {open && ( +
+ {supportedLocales.map((l) => ( + + ))} +
+ )} +
+ ); +} diff --git a/components/scene-renderers/pbl-renderer.tsx b/components/scene-renderers/pbl-renderer.tsx index 550b71da3..6a2792c3a 100644 --- a/components/scene-renderers/pbl-renderer.tsx +++ b/components/scene-renderers/pbl-renderer.tsx @@ -44,9 +44,10 @@ export function PBLRenderer({ content, mode: _mode, sceneId }: PBLRendererProps) // Add Question Agent welcome message if chat is empty and active issue has questions const activeIssue = newConfig.issueboard.issues.find((i) => i.is_active); if (activeIssue?.generated_questions && newConfig.chat.messages.length === 0) { - const welcomeMsg = t('pbl.chat.welcomeMessage') - .replace('{title}', activeIssue.title) - .replace('{questions}', activeIssue.generated_questions); + const welcomeMsg = t('pbl.chat.welcomeMessage', { + title: activeIssue.title, + questions: activeIssue.generated_questions, + }); newConfig.chat = { messages: [ { diff --git a/components/scene-renderers/pbl/use-pbl-chat.ts b/components/scene-renderers/pbl/use-pbl-chat.ts index 8c41ff85b..2708e6fc7 100644 --- a/components/scene-renderers/pbl/use-pbl-chat.ts +++ b/components/scene-renderers/pbl/use-pbl-chat.ts @@ -165,7 +165,7 @@ async function handleIssueComplete( config: PBLProjectConfig, completedIssue: PBLIssue, headers: Record, - t: (key: string) => string, + t: (key: string, options?: Record) => string, ) { // Mark current issue as done const issue = config.issueboard.issues.find((i) => i.id === completedIssue.id); @@ -226,9 +226,10 @@ async function handleIssueComplete( config.chat.messages.push({ id: `msg_${Date.now()}_welcome`, agent_name: nextIssue.question_agent_name, - message: t('pbl.chat.welcomeMessage') - .replace('{title}', nextIssue.title) - .replace('{questions}', data.message), + message: t('pbl.chat.welcomeMessage', { + title: nextIssue.title, + questions: data.message, + }), timestamp: Date.now(), read_by: [], }); @@ -241,9 +242,10 @@ async function handleIssueComplete( config.chat.messages.push({ id: `msg_${Date.now()}_welcome`, agent_name: nextIssue.question_agent_name, - message: t('pbl.chat.welcomeMessage') - .replace('{title}', nextIssue.title) - .replace('{questions}', nextIssue.generated_questions), + message: t('pbl.chat.welcomeMessage', { + title: nextIssue.title, + questions: nextIssue.generated_questions, + }), timestamp: Date.now(), read_by: [], }); @@ -253,9 +255,10 @@ async function handleIssueComplete( config.chat.messages.push({ id: `msg_${Date.now()}_system`, agent_name: 'System', - message: t('pbl.chat.issueCompleteMessage') - .replace('{completed}', completedIssue.title) - .replace('{next}', nextIssue.title), + message: t('pbl.chat.issueCompleteMessage', { + completed: completedIssue.title, + next: nextIssue.title, + }), timestamp: Date.now(), read_by: [], }); diff --git a/components/settings/agent-settings.tsx b/components/settings/agent-settings.tsx index 6978bff73..ad0c9aa8a 100644 --- a/components/settings/agent-settings.tsx +++ b/components/settings/agent-settings.tsx @@ -159,10 +159,9 @@ export function AgentSettings({ {t('settings.multiAgentMode')} -{' '} - {t('settings.agentsCollaboratingCount').replace( - '{count}', - String(selectedAgentIds.length), - )} + {t('settings.agentsCollaboratingCount', { + count: selectedAgentIds.length, + })} )} diff --git a/components/whiteboard/whiteboard-history.tsx b/components/whiteboard/whiteboard-history.tsx index 853292f43..e89274214 100644 --- a/components/whiteboard/whiteboard-history.tsx +++ b/components/whiteboard/whiteboard-history.tsx @@ -142,10 +142,7 @@ export function WhiteboardHistory({ isOpen, onClose }: WhiteboardHistoryProps) {
{formatTime(snap.timestamp)} ·{' '} - {t('whiteboard.elementCount').replace( - '{count}', - String(snap.elements.length), - )} + {t('whiteboard.elementCount', { count: snap.elements.length })}