Sub Translate
For i = 0 To 100
Sleep(200)
Wait For (MyMemory("Test text","en","zh")) Complete (result As String)
Log(result)
Next
End Sub
Sub MyMemory(source As String,sourceLang As String,targetLang As String) As ResumableSub
Dim email As String = "test@163.com"
Dim su As StringUtils
source=su.EncodeUrl(source,"UTF-8")
Dim job As HttpJob
job.Initialize("job",Me)
Dim langpair As String
langpair=sourceLang&"|"&targetLang
langpair=su.EncodeUrl(langpair,"UTF-8")
Dim param As String
param="?q="&source&"&langpair="&langpair
If email<>"" Then
param=param&"&de="&email
End If
job.Download("https://api.mymemory.translated.net/get"¶m)
Dim translatedText As String=""
wait for (job) JobDone(job As HttpJob)
If job.Success Then
Try
Log(job.GetString)
Dim json As JSONParser
json.Initialize(job.GetString)
Dim response As Map
response=json.NextObject.Get("responseData")
translatedText=response.Get("translatedText")
Catch
Log(LastException)
End Try
End If
job.Release
Return translatedText
End Sub