bin/translate in shvets-google_translate-0.5.3 vs bin/translate in shvets-google_translate-0.5.4

- old
+ new

@@ -1,11 +1,11 @@ #!/usr/bin/env ruby $:.unshift(File::join(File::dirname(File::dirname(__FILE__)), "lib")) require 'rubygems' -require 'google_translate.rb' +require 'google_translate' class Translate USAGE= <<-TEXT Usage: translate list - displays the list of supported languages @@ -21,10 +21,19 @@ def print_languages list, title puts USAGE puts list.join(', ') end + def display text + if RUBY_PLATFORM =~ /mswin32/ + File.open("temp.txt", "w") {|f| f.write text } + %x[notepad temp.txt] + else + puts text + end + end + def run if(ARGV.size == 0) puts USAGE and return end @@ -42,20 +51,18 @@ when /(..):(..)/ from_text = ARGV.join(' ') from = $1 to = $2 - puts @translator.translate(from.to_sym, to.to_sym, from_text) - + display(@translator.translate(from.to_sym, to.to_sym, from_text)) when /(..)/ from_text = ARGV.join(' ') from = @translator.detect_language(from_text)['language'] to = $1 - puts @translator.translate(from.to_sym, to.to_sym, from_text) + display(@translator.translate(from.to_sym, to.to_sym, from_text)) end - end end Translate.new.run