Jump to content

Habla Usted Englese?


justapeon
 Share

Recommended Posts

Think it is neat that we can use the world of computers to translate languages even from the command line. Opens up a whole new world without ever leaving your computer. This what we did.

$ sudo apt-get update

$ sudo apt-get install wget

Translating words from the command line: (for example from italian to english.

$ ./lc.sh “Ti voglio molto bene” it en

Love you very much

$

$ ./lc.sh “Ti voglio molto bene” it zh

非常爱你

$

lc.sh

#!/bin/bash
if test -z $3; then
        echo "Usage: $0 \"<str>\" <lang1> <lang2>"
        echo "Translates string \"<str>\" from <lang1> to <lang2>"
        echo "(CLI frontend to Google Translate)"
else
wget -qO- "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=$1&langpair=$2|${3:-$3}" | sed 's/.*"translatedText":"\([^"]*\)".*}/\1\n/';
fi
echo ""

Edited by justapeon
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...