File size: 620 Bytes
9fed9f2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
const API_URL = 'https://api.mymemory.translated.net/get';
export const translateToHindi = async (text: string): Promise<string> => {
try {
const response = await fetch(
`${API_URL}?q=${encodeURIComponent(text)}&langpair=en|hi`
);
const data = await response.json();
if (data.responseStatus !== 200) {
throw new Error(data.responseDetails);
}
return data.responseData.translatedText || 'अनुवाद उपलब्ध नहीं है';
} catch (error) {
console.error('Translation error:', error);
return 'अनुवाद त्रुटि';
}
}; |