Spaces:
Running
Running
File size: 511 Bytes
947c08e |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import axios from "axios";
const translator = (from_code:string,to_code:string,text:string) => {return (async () => {
const DATA = await axios({
method: 'get',
url: `https://clients5.google.com/translate_a/t?client=dict-chrome-ex&sl=${from_code}&tl=${to_code}&q=${encodeURIComponent(text)}`,
}).then((response) => {return response.data})
.catch((error) => {console.log(error)})
if (from_code === "auto") return DATA[0][0]
else return DATA[0]
})()}
export default translator |