Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/monkey_translator.rb
Instance Method Summary collapse
Instance Method Details
#to_chinese ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/monkey_translator.rb', line 4 def to_chinese key = MKTR_CONFIG[:key] sr = MKTR_CONFIG[:source_language] || "en" ds = MKTR_CONFIG[:destination_language] || "zh-CN" query = gsub(" ", "%20") response = HTTParty.get('https://www.googleapis.com/language/translate/v2?key='+key+'&q='+query+'&source='+sr+'&target='+ds) if response["data"] response["data"]["translations"][0]["translatedText"] else "" end end |