Pages in topic:   [1 2] >
A simple Google Translate translator for API users
Thread poster: Samuel Murray

Samuel Murray  Identity Verified
Netherlands
Local time: 19:09
Member (2006)
English to Afrikaans
+ ...
Nov 3, 2016

Hello everyone

Do you know of a tool that runs in Windows that I can use to translate text files in Google Translate with, that works with my API key? I know there are some programs that perform Google Translate translations for you, but without asking for your API key (e.g. QTranslate App), but I'm looking for a tool that does so while requiring the API key. The reason I want to have this is to have that extra layer of privacy that is offered for translations done via the API key.

I know I can just upload the file to Google Translate's tool, but I want to avoid uploading/downloading files. In fact, a tool that translates the clipboard for me, would be even better.

Thanks
Samuel


Direct link Reply with quote
 
CafeTran Training
Netherlands
Local time: 19:09
Member (2016)
CafeTran Nov 3, 2016

Samuel Murray wrote:

In fact, a tool that translates the clipboard for me, would be even better.



You could use the (test version of) CafeTran for this.


Direct link Reply with quote
 

Samuel Murray  Identity Verified
Netherlands
Local time: 19:09
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
No CAT tool, thanks Nov 3, 2016

CafeTran Training wrote:
You could use the (test version of) CafeTran for this.


I'd rather not use a fully fledged CAT tool for something this simple.


Direct link Reply with quote
 

Michael Joseph Wdowiak Beijer  Identity Verified
United Kingdom
Local time: 18:09
Member (2009)
Dutch to English
+ ...
hmm Nov 3, 2016

Figure out how the Google Translate API works and build your own little app using AutoHotkey or AutoIT?

See e.g.:

"Use the Google Translate API for Free

The official Google Translate API is available for businesses only but you can use Google Apps Script to create your own Google Language Translation API without having to pay the enterprise license fee.

The text can be translated from one language to another using the LanguageApp service or, if you run out of quota, you can make a call to the secret translate.googleapis.com API that is internally used by the Google Translate extension for Chrome and requires no authentication.

You can publish the Google script and deploy it as a web app with parameters for source and target languages and the text query. You can specify any ISO language pair or say “auto” and the Google Translation API will auto detect the language of the source text.


* Written by Amit Agarwal */
/* web: ctrlq.org */

function doGet(e) {

var sourceText = ''
if (e.parameter.q){
sourceText = e.parameter.q;
}

var sourceLang = 'auto';
if (e.parameter.source){
sourceLang = e.parameter.source;
}

var targetLang = 'ja';
if (e.parameter.target){
targetLang = e.parameter.target;
}

/* Option 1 */

var translatedText = LanguageApp.translate(sourceText, sourceLang, targetLang)

/* Option 2 */

var url = "https://translate.googleapis.com/translate_a/single?client=gtx&sl="
+ sourceLang + "&tl=" + targetLang + "&dt=t&q=" + encodeURI(sourceText);

var result = JSON.parse(UrlFetchApp.fetch(url).getContentText());

translatedText = result[0][0][0];

var json = {
'sourceText' : sourceText,
'translatedText' : translatedText
};

// set JSONP callback
var callback = 'callback';
if(e.parameter.callback){
callback = e.parameter.callback
}

// return JSONP
return ContentService
.createTextOutput(callback + '(' + JSON.stringify(json) + ')')
.setMimeType(ContentService.MimeType.JAVASCRIPT);
}
" (https://ctrlq.org/code/19909-google-translate-api )

and:

https://cloud.google.com/translate/docs/ (tons of great, clear info)


Direct link Reply with quote
 

Samuel Murray  Identity Verified
Netherlands
Local time: 19:09
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
Okay, an AutoIt solution Nov 3, 2016

Michael Joseph Wdowiak Beijer wrote:
Figure out how the Google Translate API works and build your own little app using AutoHotkey or AutoIT?


Okay, I've done that:
http://wikisend.com/download/197472/simplegoog.zip


Direct link Reply with quote
 

Samuel Murray  Identity Verified
Netherlands
Local time: 19:09
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
I wrote a little script Nov 12, 2016

Michael Joseph Wdowiak Beijer wrote:
Figure out how the Google Translate API works and build your own little app using AutoHotkey or AutoIT?


Did that. Here is the updated version of it:
http://www.leuce.com/autoit/simplegoog.zip

The readme file says:

simplegoog v3 ###.au3

Simplegoog is a simple script to translate text file using Google Translate via die paid API key. It requires a paid Google Translate API key to work.

Rename the script with your details. Say your API key is 12345 and you want to translate from German to English, then rename "simplegoog v3 ###" to "simplegoog v3 #12345#de#en".

The AU3 file must be double-clicked to work (you need to install AutoIt). You can also double-click the EXE file, if you like (don't have to install AutoIt).

If you double-click, you'll be asked whether you want to translate the clipboard or a file. If you translate a file, you have to select the input file. If you translate the clipboard, the translation will be put on the clipboard at the end. Or: you can drag and drop your input file onto the EXE file, and it will process the input file.

The output file is the input file with "_output.txt" appended to it's file name. The script does not overwrite existing files but appends to it. The input format is plain text, UTF8 with BOM, with preferably one sentence per line. If the lines are too long, we can't send them to Google.




[Edited at 2016-11-12 00:40 GMT]


Direct link Reply with quote
 
CafeTran Training
Netherlands
Local time: 19:09
Member (2016)
Screenshot? Nov 12, 2016

Samuel Murray wrote:

Did that. Here is the updated version of it:
http://www.leuce.com/autoit/simplegoog.zip


I'm not using Windows but I'd be interested to have a look at your code. Could you please post a screenshot of the AutoIt macro?

Thanks in advance!


Direct link Reply with quote
 

Michael Joseph Wdowiak Beijer  Identity Verified
United Kingdom
Local time: 18:09
Member (2009)
Dutch to English
+ ...
Nothing to see here, ... Nov 12, 2016

... move along folks.

[Edited at 2016-11-12 17:12 GMT]


Direct link Reply with quote
 

Michael Joseph Wdowiak Beijer  Identity Verified
United Kingdom
Local time: 18:09
Member (2009)
Dutch to English
+ ...
Cool! Nov 12, 2016

Samuel Murray wrote:

Michael Joseph Wdowiak Beijer wrote:
Figure out how the Google Translate API works and build your own little app using AutoHotkey or AutoIT?


Did that. Here is the updated version of it:
http://www.leuce.com/autoit/simplegoog.zip

The readme file says:

simplegoog v3 ###.au3

Simplegoog is a simple script to translate text file using Google Translate via die paid API key. It requires a paid Google Translate API key to work.

Rename the script with your details. Say your API key is 12345 and you want to translate from German to English, then rename "simplegoog v3 ###" to "simplegoog v3 #12345#de#en".

The AU3 file must be double-clicked to work (you need to install AutoIt). You can also double-click the EXE file, if you like (don't have to install AutoIt).

If you double-click, you'll be asked whether you want to translate the clipboard or a file. If you translate a file, you have to select the input file. If you translate the clipboard, the translation will be put on the clipboard at the end. Or: you can drag and drop your input file onto the EXE file, and it will process the input file.

The output file is the input file with "_output.txt" appended to it's file name. The script does not overwrite existing files but appends to it. The input format is plain text, UTF8 with BOM, with preferably one sentence per line. If the lines are too long, we can't send them to Google.




[Edited at 2016-11-12 00:40 GMT]


Looks very interesting.

I currently have very similar functionality inside of Déjà Vu X3 (just select sth and press Ctrl+G, and your selection will be automatically translated by any of your connected MT providers), but I bet your script could be quite useful in various contexts. In fact, if you polished it up a bit it might be an interesting alternative for some people to GT4T (http://gt4t.net/en/ ). I will probably play around with it a bit and start using it when not working in DVX3.

Michael


Direct link Reply with quote
 

Samuel Murray  Identity Verified
Netherlands
Local time: 19:09
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
@CafeTran and @Michael Nov 12, 2016

CafeTran Training wrote:
Samuel Murray wrote:
Did that. Here is the updated version of it:
http://www.leuce.com/autoit/simplegoog.zip

I'm not using Windows but I'd be interested to have a look at your code. Could you please post a screenshot of the AutoIt macro?


The zip file contains the AU3 file, which is a plain text file with the script's code in it. You should be able to unzip the file on any operating system. The script's idea is quite simple but it has become fairly complicated due to all kinds of things that went wrong during testing, and because I'm not a very bad programmer.

I initially thought that I'd be using the drag-and-drop method most, but it turns out that translating the clipboard is faster and easier in most cases, and for that you don't need to use the EXE version.

Michael Joseph Wdowiak Beijer wrote:
I currently have very similar functionality inside of Déjà Vu X3 (just select sth and press Ctrl+G, and your selection will be automatically translated by any of your connected MT providers), but I bet your script could be quite useful in various contexts.


It's useful to me because it does not require me to interact with a CAT tool.

In fact, if you polished it up a bit it might be an interesting alternative for some people to GT4T (http://gt4t.net/en/ ).


Polishing it up may include adding a proper GUI, etc. But I think I've reached my limit of polishing on this script. I've spent quite a bit of time troubleshooting the most mysterious problems, and even now it's provided "as is". In fact, I wouldn't be surprised if lots of little issues rear their heads as soon as the script gets tested with languages other than my own.

An example of a weird problem is that last night I discovered was that the script did not work if there were fewer than a certain number of segments to translate (but I managed to fix that). Another weird issue was that sometimes the last few lines were translated a second time, or the second-to-last lines were translated a second time but the last few lines were not translated (but I eventually managed to fix that as well). There comes a point at which el hyphen users like myself must say "okay, it works good enough".

[Edited at 2016-11-12 13:55 GMT]


Direct link Reply with quote
 

Samuel Murray  Identity Verified
Netherlands
Local time: 19:09
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
Version 5 of SimpleGoog, now works with non-ASCII characters Nov 19, 2016

Hello everyone

I've updated SimpleGoog in such a way that it hopefully now reads non-ASCII characters. I've tested it with Arabic and Russian and it appears to work. The download location is the same: http://www.leuce.com/autoit/simplegoog.zip

Please test it to see if it really works. There may be characters that Google does not want to be escaped, and I simply haven't stumbled upon them, so there is a small chance that the script might not work for you.

If you simply double-click SimpleGoog, it'll ask for your API key and language codes. You can prevent it from asking each time, by reading the readme.txt.

There is no virus, but if you don't believe me, then install AutoIt and run the AU3 file (which you can open in Notepad) instead of the EXE file.

At this time, if you choose to translate the clipboard, it can only translate the clipboard if the clipboard was copied as plain text.

Samuel


Direct link Reply with quote
 

Shouguang Cao
China
Local time: 02:09
Member (2007)
English to Chinese
+ ...
no extra layer Jul 6

Using your own API key won't give you an extra layer of privacy.

Direct link Reply with quote
 

Samuel Murray  Identity Verified
Netherlands
Local time: 19:09
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
@Dallas Jul 6

Dallas Cao wrote:
Using your own API key won't give you an extra layer of privacy.


What is your source for that information?

-------------------------------------------------------------------------

By the way, somehow the script got deleted from my FTP site. So I uploaded it again. Here are the versions currently available:

For premium Google Translate:

http://www.leuce.com/autoit/simplegoog%20premium%20v7%20OMEGAT.zip
http://www.leuce.com/autoit/simplegoog%20premium%20v7%20SHORTCUT%20for%20self-compile.zip
http://www.leuce.com/autoit/simplegoog%20premium%20v7%20SHORTCUT.zip
http://www.leuce.com/autoit/simplegoog%20premium%20v7.zip

For non-premium Google Translate:

http://www.leuce.com/autoit/simplegoog.zip



[Edited at 2017-07-06 08:54 GMT]


Direct link Reply with quote
 

Shouguang Cao
China
Local time: 02:09
Member (2007)
English to Chinese
+ ...
here you go Jul 6

The api key is simply an authentication with Google server and it doesn't contain any personal information, whoever's api key you are using, you submit your text directly to google translate API and the process is identical.

Here is what happened:
1. You send an API key along with source text to Google.
2. Google says yes, the API key is valid. Send back translation.

How come using your own key give you an extra layer of privacy?

Of course in another scenario, when you use other people's API.

1. You submit your text to the API key'owners server.
2. That private server requests translation from google and then return the translation back to you.

Then using others' key and your own key is no longer the same.

And the third scenario: danger! Using your own key with the third party program, and the third party is rouge. Then it steals your api key and therefore can spend your money. Of course Samuel you are doing an open source program, you won't do that.



Samuel Murray wrote:

Dallas Cao wrote:
Using your own API key won't give you an extra layer of privacy.


What is your source for that information?

-------------------------------------------------------------------------

By the way, somehow the script got deleted from my FTP site. So I uploaded it again. Here are the versions currently available:

For premium Google Translate:

http://www.leuce.com/autoit/simplegoog%20premium%20v7%20OMEGAT.zip
http://www.leuce.com/autoit/simplegoog%20premium%20v7%20SHORTCUT%20for%20self-compile.zip
http://www.leuce.com/autoit/simplegoog%20premium%20v7%20SHORTCUT.zip
http://www.leuce.com/autoit/simplegoog%20premium%20v7.zip

For non-premium Google Translate:

http://www.leuce.com/autoit/simplegoog.zip



[Edited at 2017-07-06 08:54 GMT]


Direct link Reply with quote
 

Samuel Murray  Identity Verified
Netherlands
Local time: 19:09
Member (2006)
English to Afrikaans
+ ...
TOPIC STARTER
@Dallas Jul 7

Dallas Cao wrote:
Whoever's API key you are using, you submit your text directly to the Google Translate API and the process is identical.


1. Google charges money for the API-based translations. A third-party tool would quickly run up a large bill if thousands of users were to use it without paying, unless (a) they have philanthropic sponsors or (b) they don't pay money to use the API. If a tool therefore offers API-based translations for free, then one wonders what kind of a deal they privately have with Google.

2. Unless you're a programmer, and unless you have access to the tool's source code, you can only rely on the tool's developer's reputation to be sure that your text is submitted directly to Google Translate and only to Google Translate, and that either your text or the response from Google Translate is not captured.

But...

How come using your own key give you an extra layer of privacy?


...I think you misunderstood what I wrote: The reason I want to have this is to have that extra layer of privacy that is offered for translations done via the API key.

The extra layer of privacy comes from using an API key (regardless of whose key it is), because Google Translate's terms of service for API-based translations differ from that of the public web-based translation service. Google claims that text that is submitted via the API-service are treated with greater confidentiality and privacy than text submitted through their web-based translator.


Direct link Reply with quote
 
Pages in topic:   [1 2] >


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

A simple Google Translate translator for API users

Advanced search







SDL Trados Studio 2017 Freelance
The leading translation software used by over 250,000 translators.

SDL Trados Studio 2017 helps translators increase translation productivity whilst ensuring quality. Combining translation memory, terminology management and machine translation in one simple and easy-to-use environment.

More info »
memoQ translator pro
Kilgray's memoQ is the world's fastest developing integrated localization & translation environment rendering you more productive and efficient.

With our advanced file filters, unlimited language and advanced file support, memoQ translator pro has been designed for translators and reviewers who work on their own, with other translators or in team-based translation projects.

More info »



Forums
  • All of ProZ.com
  • Term search
  • Jobs
  • Forums
  • Multiple search