Google Translate with speech synthesis in your terminal as ruby gem
Ruby
Latest commit 5ec0a97 Dec 19, 2015 @pawurb google broke
Failed to load latest commit information.
bin
lib
spec commit vcr cassetes Aug 25, 2015
.gitignore
.rspec
.travis.yml
Gemfile
LICENSE.txt
README.md
Rakefile
termit.gemspec

README.md

Termit Build Status Gem Version Coverage Status

Termit is an easy way to use Google Translate in your terminal. You can check out its node.js npm version normit

Status

Looks like Google blocked the APIs needed for it to work and project is no longer functional.

Installation

gem install termit

Usage

termit 'source_language' 'target_language' 'text'

Example:

termit en es "hey cowboy where is your horse?"
=> "Hey vaquero dónde está tu caballo?"

termit fr en "qui est votre papa?"
=> "Who's Your Daddy?"

Parenthesis are not necessary for text data input:

termit fr ru qui est votre papa?
=> "Кто твой папочка?"

Speech synthesis

Specify a -t (talk) flag to use speech synthesis (requires mpg123):

termit en zh "hey cowboy where is your horse?" -t
=> "嘿,牛仔是你的马在哪里?" # and a chinese voice says something about a horse

You can use termit as a speech synthesizer of any supported language without having to translate anything:

termit en en "hold your horses cowboy !" -t
=> "hold your horses cowboy !" # and an english voice asks you to hold on

Synonyms

Specify a -s (synonyms) flag to get the list of synonyms if available:

termit es en muchacho -s
=> boy
=> Synonyms: boy, lad, youngster, laddie, cully

Learning language when committing to git

Idea by Nedomas. See and hear your messages translated to target lang every time you commit. You can do this two ways: overriding the git command, and using a post-commit hook in git.

Override the git command (zsh only)

In ~/.zshrc

export LANG=es
git(){[[ "$@" = commit\ -m* ]]&&termit en $LANG ${${@:$#}//./} -t;command git $@}

I am no shell ninja so if you know how to make it work in bash then please submit a PR.

Using a post-commit hook

Add a file named post-commit to your project's .git/hooks directory, with this in it:

termit en es "`git log -1 --pretty=format:'%s'`" -t

Remember to switch the languages according to your preference.

If you want this to be in every one of your git repositories, see this Stack Overflow answer.

Language codes:

  • english - en
  • polish - pl
  • french - fr
  • spanish - es
  • slovakian - sk
  • chinese - zh
  • russian - ru
  • automatic source language detection - auto

To find all available language codes visit https://developers.google.com/translate/v2/using_rest#language-params.

Requirements

Works with Ruby 1.9.2 and higher.

To use speech synthesis you need to have mpg123 installed.

For Ubuntu:

sudo apt-get install mpg123

For MacOSX:

brew install mpg123