
php-google-translator
install
- download zip file, and extract it.
wget http://code.google.com/p/php-google-translator/downloads/detail?name=php-google-translator.zip
- unzip the file you downloaded
gunzip php-google-translator.zip
- copy the file to /usr/local/bin.
sudo cp ./translator.php /usr/local/bin
- change the file mode to executable
sudo chmod +x /usr/local/bin/translator.php
- modify your shell setting (if you are using bashrc)
vim ~/.bashrc
- add this line to your bashrc file.
alias translate='/usr/local/bin/translator.php'
- it's all done.
command line usage
roga@carlisten-lx:~$ translate The quick brown fox jumps over the lazy dog
Translate from: The quick brown fox jumps over the lazy dog
Translate into: 快速棕色狐狸跳過了懶惰的狗
deep inside (example PHP code)
```
unset($argv[0]); $source = implode($argv, ' '); $translator = new translator();
$result = $translator->translate($source, "en", "zh-TW");
echo "$source = $result" . PHP_EOL; ```