sermoa / ruby_translate
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Branch:
master
| name | age | message | |
|---|---|---|---|
| |
.gitignore | ||
| |
MIT-LICENSE | ||
| |
README | ||
| |
lib/ | ||
| |
ruby_translate.gemspec |
README
RubyTranslate provides a simple wrapper around the Google Translate API for detecting and translating languages.
Usage:
gem install sermoa-ruby_translate
require 'ruby_translate'
Detect:
RubyTranslate.detect("Mein Luftkissenfahrzeug ist voller Aale")
=> "de"
RubyTranslate.detect("Safisha viatu yangu mara moja!")
=> "sw"
Translate:
RubyTranslate.translate("Mein Luftkissenfahrzeug ist voller Aale", "en")
=> "My hovercraft is full of eels"
RubyTranslate.translate("Il y a un singe qui vole dans l'arbre.", "en")
=> "There is a flying monkey in the tree."
RubyTranslate.translate("They are singing in St Peter's Square", "it")
=> "Essi sono il canto, in Piazza San Pietro"
RubyTranslate.translate("Eu queria um outro pedacinho de Apfelstrudel, por favor", "sv", "pt")
=> "Jag ville ha en bit av Apfelstrudel, tack"
languages = ["it", "fr", "de", "es", "pt", "ru", "pl"]
languages.each{|language| puts RubyTranslate.translate("All human beings are born free and equal in dignity and
rights.", language, "en")}
Tutti gli esseri umani nascono liberi ed eguali in dignità e diritti.
Tous les êtres humains naissent libres et égaux en dignité et en droits.
Alle Menschen sind frei geboren und gleich an Würde und Rechten.
Todos los seres humanos nacen libres e iguales en dignidad y derechos.
Todos os seres humanos nascem livres e iguais em dignidade e em direitos.
Все люди рождаются свободными и равными в своем достоинстве и правах.
Wszyscy ludzie rodzą się wolni i równi pod względem swej godności i swych praw.
Note that the 'from' parameter is optional - if you do not provide it, RubyTranslate first uses detect to guess which
language it is.
Acknowledgements:
Thanks to the following excellent sources for inspiration:
* http://ruby.geraldbauer.ca/google-translation-api.html
* http://github.com/elisehuard/google_translate/tree/master
* http://github.com/sishen/rtranslate/tree/master
* http://www.omniglot.com/language/phrases/hovercraft.htm
* http://www.omniglot.com/language/phrases/useful.htm
* http://www.un.org/en/documents/udhr/

