Class: AbAdmin::I18nTools::TranslateApp

Inherits:
Object
  • Object
show all
Defined in:
lib/ab_admin/i18n_tools/translate_app.rb

Class Method Summary collapse

Class Method Details

.call(env) ⇒ Object


4
5
6
7
8
9
10
11
12
# File 'lib/ab_admin/i18n_tools/translate_app.rb', line 4

def self.call(env)
  if env['warden'].user
    params = Rack::Request.new(env).params
    body = {text: AbAdmin::I18nTools::GoogleTranslate.t(params['q'], params['from'], params['to'])}
    [200, {'Content-Type' => 'application/json'}, body.to_json]
  else
    [401, {'Content-Type' => 'application/json'}, '']
  end
end