Sha256: 8b24a6dbe918a699b87feaa59bc61f619b2c72fb4083c9a51e335bb72e5eca7a

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

#!/usr/bin/env ruby

$:.unshift(File::join(File::dirname(File::dirname(__FILE__)), "lib"))

require 'google_translate/translate_cli'

if ARGV.size == 0
  puts TranslateCLI::USAGE
elsif ARGV.size == 1
  if ARGV[0] == 'version' or ARGV[0] == '--version' or ARGV[0] == '-v'
    TranslateCLI.start ["version"]
  elsif ARGV[0] == 'list'
    TranslateCLI.start ["list"]
  end
else
  params = []
  say = ENV['say'] ? (ENV['say'] == 'true') : false
  extra = ENV['extra'] ? (ENV['extra'] == 'true') : false

  index = 0

  while index < ARGV.size do
    param = ARGV[index]

    if param =~ /--say/ or param =~ /-s/
      say = true
    elsif param =~ /--extra/ or param =~ /-e/
      extra = true
    else
      params << param
    end

    index = index + 1
  end

  from, to, text = case params.shift
    when /(.*):(.*)/ then
      [$1, $2, params.join(' ')]
    when /(.*)/ then
      ["auto", $1, params.join(' ')]
    else
      ['en', '', '']
  end

  TranslateCLI.start ["translate", "--say=#{say}", "--extra=#{extra}", from.to_sym, to.to_sym, text]
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
google-translate-1.1.3 bin/translate
google-translate-1.1.2 bin/translate
google-translate-1.1.1 bin/translate
google-translate-1.1.0 bin/translate