﻿
simplegoog v3 ###.au3
(Samuel Murray, 11 Nov 2016)

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 can also double-click the EXE file, if you like.  If you double-click, you'll be asked whether you want to translate the clipboard, or a a file, and if 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.

You can drag and drop your input file onto the EXE file, and it will process the input file.  

The output file is the inputfile with "_output.txt" appended to it's file name.  The script does not overwrite existing files but appends to it.

The script comes with built-in abbreviations for English source text, but you can specify your own abbreviations in a separate file called abbreviationlist.txt in the same folder as the script.  This is a very primitive feature, by the way.  If abbreviationlist.txt exists, the script will assume that you want to segment by sentence.

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.

==

Issues

1. The sentence segmentation is also very, very primitive.  Quite klunky, in fact.  It's just there to prevent overlong segments.  I haven't extensively tested the loading of external abbreviations.
2. URL escaping is unfinished, so the script sends mostly  raw text to Google, and then converts a few things upon return.  Not all non-alphabetical characters must be escaped (I tried it, it doesn't work that way), but some characters must be escaped.  If the script fails to translate your entire file, then this may be a reason: there is a character in your file that must be escaped.  For example, I recently discovered that = and # must be escaped, so I added that to the escape list.  TODO: make an external escape list.
3. Empty lines are not preserved.  I don't know how to tell Google to send back empty lines, and the script's output is based entirely on what Google sends back.

==

version 2: fixed bug in which % in URL caused URL to fail.
version 3: reverted a feature in version 2 that tried to suppress prompts.  If you want to suppress prompts, install AutoIt and edit the script yourself and recompile it (if you want).

