Türkçe çeviri özelliği eklendi (GLM 4.6 ile çeviri yapılıyor)

This commit is contained in:
2025-11-16 23:02:15 +03:00
parent cd0b59945b
commit daf39e35c0
9 changed files with 446 additions and 8 deletions

View File

@@ -0,0 +1,25 @@
const API_BASE = import.meta.env.VITE_API_BASE_URL || 'http://localhost:4000';
export const translateChunkToTurkish = async (text) => {
if (!text?.trim()) {
throw new Error('Çevrilecek metin bulunamadı.');
}
const response = await fetch(`${API_BASE}/translate`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text }),
});
if (!response.ok) {
const message = await response.text();
throw new Error(message || 'Çeviri isteği başarısız oldu.');
}
const payload = await response.json();
if (!payload?.text) {
throw new Error('Çeviri yanıtı boş döndü.');
}
return payload.text.trim();
};