Last active
August 29, 2015 14:08
-
-
Save nbhartiya/59ed2673b35e97d07f2e to your computer and use it in GitHub Desktop.
Ruby vs Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import goslate | |
import random | |
class Trans: | |
def __init__(self, language): | |
self.gs = goslate.Goslate() | |
self.language = language | |
def translate(self,word): | |
print self.gs.translate(word, self.language) | |
class People: | |
def __init__(self): | |
self.potl_people = {'French_Speaker':'bonjour', 'German_Speaker':'hallo', 'Spanish_Speaker':'hola'} | |
self.person = random.choice(self.potl_people.keys()) | |
print self.person | |
def says(self): | |
return self.potl_people[self.person] | |
x=Trans('en') | |
person1 = People() | |
person2 = People() | |
x.translate(person1.says()) | |
y = Trans('de') | |
y.translate(person1.says()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'google_translate' | |
print "Tell us a word: " | |
word = gets.chomp | |
print "What language do you want to translate to? " | |
language = gets.chomp | |
class Trans | |
def initialize(language) | |
@language = language | |
end | |
def translator(word) | |
t = GoogleTranslate.new() | |
translation = t.translate("en",@language,word)[0][0][0] | |
puts translation | |
#print translation | |
end | |
end | |
Trans.new(language).translator(word) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment