Class: I18nAdminUtils::TranslationController

Inherits:
ApplicationController show all
Defined in:
app/controllers/i18n_admin_utils/translation_controller.rb

Instance Method Summary collapse

Instance Method Details

#editObject

[View source]

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/i18n_admin_utils/translation_controller.rb', line 6

def edit
  if params[:key].nil?
    i18n_redirect('No key specified')
  else
    key = params[:key]
    locale = params[:locale]
    translation = params[:value]
    if locale.nil?
      if key.include? '.'
        split = key.split('.', 2)
        locale = split[0]
        key = split[1]
      else
        i18n_redirect('No locale specified', false)
        return
      end
    end
    I18nAdminUtils::Backend::Manager.save_translation(locale, key, translation)
    i18n_redirect('Translation edited with success')
  end
end

#i18n_redirect(message, success = true) ⇒ Object

[View source]

40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/i18n_admin_utils/translation_controller.rb', line 40

def i18n_redirect(message, success = true)
  if request.xhr?
    render :json => {:success => success, :message => message}
  else
    if success
      redirect_to :back, :notice => message
    else
      redirect_to :back, :alert => message
    end
  end
end

#indexObject

[View source]

3
4
# File 'app/controllers/i18n_admin_utils/translation_controller.rb', line 3

def index
end

#missing_listObject

Return a list of all the missing translation

[View source]

35
36
37
38
# File 'app/controllers/i18n_admin_utils/translation_controller.rb', line 35

def missing_list
  translations = I18nAdminUtils::SearchTranslation.search
  render :partial => 'missing_list', :layouts => false, :locals => {:translations => translations}
end

#showObject

[View source]

28
29
30
31
32
# File 'app/controllers/i18n_admin_utils/translation_controller.rb', line 28

def show
  unless params[:translation].nil?
    render :partial => 'show', :locals => {:translation => params[:translation]}
  end
end