Google Translate

translate(){ wget -qO- "$1&langpair=$2|${3:-en}" | sed 's/.*"translatedText":"\([^"]*\)".*}/\1\n/'; }
Usage: translate <phrase> <source-language> <output-language> Example: translate hello en es See this for a list of language codes:
Sample Output

2010-03-08 03:15:48

6 Alternatives + Submit Alt

  • allow multiword translations Show Sample Output

    translate() { lng1="$1";lng2="$2";shift;shift; wget -qO- "${@// /+}&langpair=$lng1|$lng2" | sed 's/.*"translatedText":"\([^"]*\)".*}/\1\n/'; }
    bandie91 · 2010-05-02 22:15:30 7
  • substitute "example" with desired string; tl = target language (en, fr, de, hu, ...); you can leave sl parameter as-is (autodetection works fine) Show Sample Output

    wget -U "Mozilla/5.0" -qO - "" | sed 's/\[\[\[\"//' | cut -d \" -f 1
    sairon · 2011-03-06 13:46:16 0
  • translate <phrase> <source-language> <output-language> works from command line

    cmd=$( wget -qO- "$1&langpair=$2|${3:-en}" | sed 's/.*"translatedText":"\([^"]*\)".*}/\1\n/'; ); echo "$cmd"
    dtolj · 2010-03-13 01:09:00 0
  • Translates a string from English to Portuguese by using google translator web service. Show Sample Output

    curl -s -A "Mozilla" "" | awk -F'"' '{print $2}'
    gean01 · 2011-07-03 00:11:52 0
  • translate <some phrase> [output-language] [source-language] 1) "some phrase" should be in quotes 2) [output-language] - optional (default: English) 3) [source-language] - optional (default: auto) translate "bonjour petit lapin" hello little rabbit translate "bonjour petit lapin" en hello little rabbit translate "bonjour petit lapin" en fr hello little rabbit Show Sample Output

    translate(){wget -U "Mozilla/5.0" -qO - "${3:-auto}&tl=${2:-en}&dt=t&q=$1" | cut -d'"' -f2}
    klisanor · 2014-06-10 12:08:51 2

What Others Think

sputnick · 595 weeks and 1 day ago
Also try: translate(){ curl -s "$(curl -s "$1" | sed 's/.*"language":"\([^"]*\)".*/\1^C/')%7C$2" | sed 's/.*{"translatedText":"\([^"]*\)".*/\1\n/' Will fetch the source language for you.
matthewbauer · 595 weeks and 1 day ago
translate(){ curl -s "$(curl -s "$1" | sed 's/.*"language":"\([^"]*\)".*/\1^C/')%7C$2" | sed 's/.*{"translatedText":"\([^"]*\)".*/\1\n/'; }
matthewbauer · 595 weeks and 1 day ago
Actually, if you leave the source language blank, it will guess it anyway and it's normally pretty successful. Also, you can have the command translate to English if you don't provide a language to translate to by using a default value for the second parameter, like this: translate(){ wget -qO- "$1&langpair=%7C${2:-en}" | sed 's/.*{"translatedText":"\([^"]*\)".*/\1\n/'; }
eightmillion · 595 weeks ago
In bash it doesn't work with spaces or accentuated letters (in french for example). This one does it (accentuated, bash working, and guessing source language if not provided) : translate(){ curl -s "`perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$1"`&langpair=`if [ "$3" != "" ]; then echo $2; fi;`%7C`if [ "$3" == "" ]; then echo $2; else echo $3; fi;`" | sed 's/{"responseData": {"translatedText":"\([^"]*\)".*}, .*}/\1\n/'; }
fab4am · 595 weeks ago
ok the wget one seems to work too with spaces and accents
fab4am · 595 weeks ago
how do you know the abbreviations for languages? link please.
kjowens · 592 weeks and 2 days ago
{ "responseData": null, "responseDetails": "Suspected Terms of Service Abuse. Please see", "responseStatus": 403 }
vp_arth · 404 weeks and 5 days ago
Google translate is the main topic but except from that there is nothing for peope to know what the main topic is all about and in any context for us. We all need to try for papers owl reviews as it was of a major help that can be of a major help.
sadamn · 58 weeks and 6 days ago
Our prior goal is to surpass all the expectations of our client by providing outstanding customer support service, greater value and increased flexibility which in results optimize system functionality and improve operation efficiency. erp software development company and erp company in india and erp for Construction and pharmacy management system
delhis · 58 weeks and 3 days ago
KGF123 · 58 weeks and 2 days ago
We are best Professional SEO, Digital Marketing, Web Designing and Web Development Company in Bangalore. social media marketing company in bangalore and web designing company in bangalore and digital marketing company in bangalore and seo services company in bangalore and PPC agency
delhis · 55 weeks and 6 days ago
We all come to work everyday to solve the most basic to the most complex visa related problems. We are passionate about providing you best suited solution to your needs. canada visa immigration lawyer and crs score
delhis · 55 weeks and 6 days ago
As we know translation is the process of converting any written content to different language formats. I have tried to follow some of the site options where you can get the best writing translation service to translate the content in an effective way.The translation service provides the best writing options to get the best writing content platform.
term67 · 38 weeks and 6 days ago
New York City comprises 5 boroughs sitting where the Hudson River meets the Atlantic Ocean. While MaxRemind top rank medical billing company of USA offers Medical Billing Services in New York, we also offer medical credentialing services in New York.
stevematt · 27 weeks and 6 days ago
We should like that being close to God is truly critical for the whole individuals. You can visit homepage for getting wonderful info. It will ensure about comfort and rapture our lives.
Ahmed74 · 24 weeks and 3 days ago
The Minus Man is a record of an impolite reformist killer who is crossing the measure of his cutoff networks for his pleasure. Visit homepage for more info. I was so scared while seeing an insane individual who was executing humble individuals.
Ahmed74 · 24 weeks and 3 days ago
The dispatch of Iceland's Food Warehouse has given me epic fulfillment. Check this homepage to read more info. Seeing the central shot of each new business open entryway ceaselessly fulfills me.
Ahmed74 · 24 weeks and 3 days ago
I'm feeling so baffled for that unprotected canine who by chance drank Palm oil. You can visit for getting wonderful info. As shown by my point of view, the owner of this canine is the standard clarification for the impulsiveness.
Ahmed74 · 20 weeks and 6 days ago
This Portable Mediachance is offering express tremendous highlights that are totally unprecedented for people like me. One hire this to do work at time. Finally it has gotten my cared for machine.
Ahmed74 · 20 weeks and 6 days ago
So glad I found this. I am planning to build a code like google translate for my business.
TylerCamarillo · 15 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: