commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
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:
Usage:
translate <phrase> <source-language> <output-language>
Example:
translate hello en es
See this for a list of language codes:
There are 2 alternatives - vote for the best!
substitute "example" with desired string;
tl = target language (en, fr, de, hu, ...);
you can leave sl parameter as-is (autodetection works fine)
Translates a string from English to Portuguese by using google translator web service.
If you can do better, submit your command here.
You must be signed in to comment.
See https://redmine.sputnick-area.net/projects/show/polytranslator
Also try:
translate(){ curl -s "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=hi&langpair=$(curl -s "http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q=$1" | sed 's/.*"language":"\([^"]*\)".*/\1^C/')%7C$2" | sed 's/.*{"translatedText":"\([^"]*\)".*/\1\n/'Will fetch the source language for you.
translate(){ curl -s "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=hi&langpair=$(curl -s "http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q=$1" | sed 's/.*"language":"\([^"]*\)".*/\1^C/')%7C$2" | sed 's/.*{"translatedText":"\([^"]*\)".*/\1\n/'; }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- "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=$1&langpair=%7C${2:-en}" | sed 's/.*{"translatedText":"\([^"]*\)".*/\1\n/'; }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 "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=`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/'; }ok the wget one seems to work too with spaces and accents
how do you know the abbreviations for languages? link please.
See: http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes