Jump to content

bonka

Member
  • Posts

    7
  • Joined

  • Last visited

Reputation Activity

  1. Like
    bonka got a reaction from jeffbyrnes in Polyglot - yet another Google Translate workflow   
    Omg I didn't know this workflow worked again. 
     
    Big thank you's for this!
  2. Like
    bonka reacted to rice.shawn in Google translate workflow   
    It looks like Translate Shell (which used the same path) found a new way to use it. It should easily be adaptable. So this means that they didn't close it; they just changed it....
  3. Like
    bonka reacted to rice.shawn in Google translate workflow   
    I don't think it is new. The endpoint that this (and my) workflow used was unofficial, and the paid translation API has been around for quite a while. So, these just used a sort of backdoor that Google had left open. Now, the URL leads to a redirect captcha challenge that redirects nowhere.
     
    It's a pity that they closed the endpoint, but we can't be too mad because it was never official to begin with.
  4. Like
    bonka reacted to deanishe in Google translate workflow   
    What actually happens is that Google returns each sentence as a separate result, but the workflow throws away all but the first.
     
    To get multi-sentence results, open the workflow in Finder and edit the translate script in it to read as follows. This will show all the sentences in a translation. Because Alfred can't show much text in its results, I've added copy text and large type. Hit CMD+C on a result to copy the translation to the clipboard and CMD+L to show the full translation in Alfred's large type window.
    # Set locale and normalize unicode composition for international support. export LC_CTYPE="UTF-8" query="$(echo "${@:3}" | iconv -s -f UTF-8-Mac -t UTF-8)" # Retrieve and parse Google Translate answer. response="$(curl -G --data-urlencode "text=$query" --data 'client=p' --data 'sl=auto' --data "tl=$1" --silent --user-agent 'Mozilla/5.0' 'http://translate.google.com/translate_a/t' | python -c 'import sys, json; print("".join([d.get("trans", "<UNTRANSLATED>") for d in json.loads(sys.stdin.read())["sentences"]]).encode("utf-8"))')" [[ -z "$response" ]] && translation="No translation found" || translation="$response" # Write feedback. echo '<?xml version="1.0" encoding="UTF-8"?><items> <item uid="translation"> <title><![CDATA['"$translation"']]></title> <arg><![CDATA['"$translation"']]></arg> <text type="copy"><![CDATA['"$translation"']]></text> <text type="largetype"><![CDATA['"$translation"']]></text> <icon>icon.png</icon> <subtitle>”'"$query"'” in '$2'.</subtitle> </item> </items>'
×
×
  • Create New...