Skip to content

Commit b03b7d9

Browse files
Add language support and localization features
1 parent c11726a commit b03b7d9

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/components/chat/ai-chat.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import { GeminiContextLoader, createContextLoader } from '@/utils/gemini-context
55
import ChatMessageComponent from './chat-message';
66
import { IoSend, IoRefresh, IoSparkles, IoDocument, IoStop } from 'react-icons/io5';
77
import { v4 as uuidv4 } from 'uuid';
8+
import { useTranslation } from 'react-i18next';
89

910
export default function AIChat() {
11+
const { i18n } = useTranslation();
1012
const [messages, setMessages] = useState<ChatMessage[]>([]);
1113
const [inputValue, setInputValue] = useState('');
1214
const [status, setStatus] = useState<ChatStatus>(ChatStatus.IDLE);
@@ -150,13 +152,15 @@ export default function AIChat() {
150152
const terminalContext = contextLoader.current?.getCurrentTerminalContext() || '';
151153

152154
// Use the new simplified chat API - all teaching guidelines are now in backend
153-
console.log(`[AIChat] Sending message with session ${sessionId.substring(0, 8)}... (history: ${messages.length} messages)`);
155+
const currentLanguage = i18n.language || 'en';
156+
console.log(`[AIChat] Sending message with session ${sessionId.substring(0, 8)}... (history: ${messages.length} messages, language: ${currentLanguage})`);
154157
await geminiClient.current.chatWithContext(
155158
sessionId,
156159
userMessage.content,
157160
messages, // Conversation history
158161
editorContext,
159162
terminalContext,
163+
currentLanguage, // User's selected language
160164
(content: string) => {
161165
// Check if generation was aborted
162166
if (abortController.current?.signal.aborted) {

src/utils/gemini-client.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export class GeminiClient {
103103
conversationHistory: ChatMessage[] = [],
104104
editorContext: string = '',
105105
terminalContext: string = '',
106+
language: string = 'en',
106107
onStream?: (content: string) => void,
107108
signal?: AbortSignal
108109
): Promise<string> {
@@ -121,7 +122,8 @@ export class GeminiClient {
121122
content: msg.content
122123
})),
123124
editor_context: editorContext,
124-
terminal_context: terminalContext
125+
terminal_context: terminalContext,
126+
language: language
125127
};
126128

127129
console.log('Sending simplified chat request to backend');
@@ -288,6 +290,7 @@ export class GeminiClient {
288290
conversationHistory,
289291
'', // No editor context in legacy mode
290292
'', // No terminal context in legacy mode
293+
'en', // Default language for legacy mode
291294
onStream,
292295
signal
293296
);

vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default defineConfig({
6565
server: {
6666
port: 3000,
6767
proxy: {
68-
'/api': 'https://xrp-code-d-u01.wpi.edu'
68+
'/api': 'http://localhost:8000' // 'https://xrp-code-d-u01.wpi.edu'
6969
}
7070
},
7171
build: {

0 commit comments

Comments
 (0)