Sha256: ed2b3d227bb648e32fa1848bb73d919d2ee5dac4491b7876d481f77005a6b80d

Contents?: true

Size: 645 Bytes

Versions: 8

Compression:

Stored size: 645 Bytes

Contents

class MicrosoftTranslator
  CONFIG = YAML.load_file("./config/idiom.yml")
    
  class << self
    def t(value, code)
      value = URI.encode(value)
      # "http://api.microsofttranslator.com/V2/Http.svc/Translate?to=#{code}&text=#{}&appId=2CEF8B6B9CA38C6C8355B154C760C28A66E4339F"
      
      appId = CONFIG["appId"]
      result = Net::HTTP.get(URI.parse("http://api.microsofttranslator.com/V2/Http.svc/Translate?to=#{code}&text=#{value}&appId=#{appId}"))
      
      if result =~ /<string xmlns=\"http:\/\/schemas.microsoft.com\/2003\/10\/Serialization\/\">(.*)<\/string>/
        output = $1
      end
      output.to_s
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
idiom-0.5.0 lib/idiom/microsoft_translator.rb
idiom-0.4.4 lib/idiom/microsoft_translator.rb
idiom-0.4.3 lib/idiom/microsoft_translator.rb
idiom-0.4.2 lib/idiom/microsoft_translator.rb
idiom-0.4.1 lib/idiom/microsoft_translator.rb
idiom-0.3.1 lib/idiom/microsoft_translator.rb
idiom-0.4.0 lib/idiom/microsoft_translator.rb
idiom-0.3.0 lib/idiom/microsoft_translator.rb