Maxbox Starter109 Translate API
Maxbox Starter109 Translate API
Google Translate
____________________________________________________________________________
maXbox Starter 109 – Found a Google Translate endpoint
that doesn't require an API key.
“Lost in translation – post to application”.
pic:1202_transerror.png
URL: https://clients5.google.com/translate_a/t?client=dict-chrome-
ex&sl=auto&tl=en&q=bonjour
https://translate.googleapis.com/translate_a/single
Now let’s have a look at the app/script below with individual texts from
your own data to translate. For this, we wrote two useful functions. The
first one returns the text translated with the target language. The
second one accepts one sentence as an argument with language detection as
a param “auto”. Then it will show the text in JSON or as file:
Query Parameters
Query Parameter Default Notes
client dict-chrome-ex Needs to be dict-chrome-ex or else you'll get a 403 error.
1/5
Query Parameter Default Notes
sl auto Designates the source language of the text to translate.
Designates the destination language of the text to
tl (none)
translate.
q (none) Text to translate
This app allows you to translate or detect text from many different
languages. That's why I want this endpoint to be seamlessly integrated
into googletrans, with it switching between endpoints if one is facing
4xx/5xx errors.
jo:= TJSON.Create();
jo.parse(rets.datastring)
jarr:= jo.JsonArray;
if httpq.getresponsecode=200 Then result:=jarr[0].stringify
else result:='Failed:'+
itoa(Httpq.getresponsecode)+Httpq.GetResponseHeader('message');
except
writeln('EWI_HTTP: '+ExceptiontoString(exceptiontype,exceptionparam));
finally
httpq.free;
httpq:= Nil;
rets.Free;
jo.free;
end;
end;
2/5
Google Translate is now a form of augmented reality and is adapted for
educational purposes. This application provides users with tools to
translate between languages and they now include an image option; users
take a photograph of a sign, piece of paper, or other form of written
text and receive a translation in the language of their choice.
Pic: 1202_lazarus_maxbox_translator.jpg
This visual technique above used to help with the understanding about
what individual texts represent is called semantic analysis. About the
topic: https://en.wikipedia.org/wiki/Semantic_analysis_(linguistics)
I found another endpoint within the source code of one of the google
translate extensions on VSCode too.
"https://translate.googleapis.com/translate_a/single?client=gtx&dt=t + params"
// where the params are:
{
"sl": source language,
"tl": destination language,
"q": the text to translate
}
3/5
for the query: https://translate.googleapis.com/translate_a/single?
client=gtx&dt=t&sl=en&tl=ja&q=Hello, how are you today?
try:
request_result = requests.get(url, headers=headers).json()
print(request_result)
print('[In English]: ' + request_result['alternative_translations'][0]
['alternative'][0]['word_postproc'])
print('[Language Dectected]: ' + request_result['src'])
except:
pass
Pic:1202_inspect_box_tutor109.png
4/5
Conclusion:
We should probably create a way to house all of these endpoints through
one API, perhaps an interface that all of the endpoints implement.
Also maybe try to URL encode the text before sending it (and use GET as
it should not work with POST).
"Neural machine translation (NMT) systems have reached state of the art
performance in translating text and are in wide deployment. Yet little is
understood about how these systems function or how they break.
A research paper suggests improving GPT-4 performance by 30% by having it
consider why it was wrong.
Reference:
JSON Lib:
https://github.com/rilyu/json4delphi/blob/master/src/Jsons.pas
URI Builder:
https://github.com/ghquant/Delphi-EmbeddedWB/blob/master/Source/EwbUrl.pas
https://github.com/skelter/Indy/blob/master/Lib/Protocols/IdURI.pas
The script:
http://www.softwareschule.ch/examples/gtranslate.txt
5/5