Module: Babelphish

Defined in:
lib/babelphish/languages.rb,
lib/babelphish.rb,
lib/babelphish/exceptions.rb,
lib/babelphish/translator.rb,
lib/babelphish/yml_translator.rb,
lib/babelphish/html_translator.rb

Overview

a list of supported languages is available here: code.google.com/apis/ajaxlanguage/documentation/reference.html#_intro_fonje

Defined Under Namespace

Modules: Exceptions, GoogleTranslate, HtmlTranslator, Translator, YmlTranslator

Constant Summary collapse

MAX_RETRIES =
3

Class Method Summary collapse

Class Method Details

.api_versionObject


52
53
54
# File 'lib/babelphish.rb', line 52

def self.api_version
  self.settings['version']
end

.google_ajax_urlObject


44
45
46
47
48
49
50
# File 'lib/babelphish.rb', line 44

def self.google_ajax_url
  if api_version == 'v2'
    "https://www.googleapis.com/language/translate/v2"
  else
    "http://ajax.googleapis.com/ajax/services/language/"
  end
end

.load_tasksObject


70
71
72
73
74
75
76
77
78
# File 'lib/babelphish.rb', line 70

def self.load_tasks
  if File.exists?('Rakefile')
    load 'Rakefile'
    Dir[File.join(File.dirname(__FILE__), 'tasks', '**/*.rake')].each { |rake| load rake }
    return true
  else
    return false
  end
end

.set_settings(settings) ⇒ Object


66
67
68
# File 'lib/babelphish.rb', line 66

def self.set_settings(settings)
  @settings = settings
end

.settingsObject


56
57
58
59
60
61
62
63
64
# File 'lib/babelphish.rb', line 56

def self.settings
  return @settings if @settings
  babelphish_settings_file = File.join(File.expand_path("~"), ".babelphish.yml")
  if File.exist?(babelphish_settings_file)
    @settings = YAML.load_file(babelphish_settings_file)
  else
    @settings = {"api_key"=>"", "version"=>"v1"}
  end
end