Class: Tolk::LocalesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/tolk/locales_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate, #ensure_no_primary_locale

Methods included from Pagination::Methods

#pagination_method, #pagination_param

Instance Method Details

#allObject



32
33
34
# File 'app/controllers/tolk/locales_controller.rb', line 32

def all
  @phrases = @locale.phrases_with_translation(params[pagination_param])
end

#createObject



41
42
43
44
# File 'app/controllers/tolk/locales_controller.rb', line 41

def create
  Tolk::Locale.create!(locale_params)
  redirect_to :action => :index
end

#dump_allObject



46
47
48
49
50
51
# File 'app/controllers/tolk/locales_controller.rb', line 46

def dump_all
  Tolk::Locale.dump_all
  I18n.reload!
  I18n::JS.export if defined? I18n::JS
  redirect_to request.referrer
end

#indexObject



6
7
8
# File 'app/controllers/tolk/locales_controller.rb', line 6

def index
  @locales = Tolk::Locale.secondary_locales.sort_by(&:language_name)
end

#showObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/tolk/locales_controller.rb', line 10

def show
  respond_to do |format|
    format.html do
      @phrases = @locale.phrases_without_translation(params[pagination_param])
    end

    format.atom { @phrases = @locale.phrases_without_translation(params[pagination_param]).per(50) }

    format.yaml do
      data = @locale.to_hash
      render :plain => Tolk::YAML.dump(data)
    end

  end
end

#statsObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/tolk/locales_controller.rb', line 53

def stats
  @locales = Tolk::Locale.secondary_locales.sort_by(&:language_name)

  respond_to do |format|
    format.json do
      stats = @locales.collect do |locale|
        [locale.name, {
          :missing => locale.count_phrases_without_translation,
          :updated => locale.count_phrases_with_updated_translation,
          :updated_at => locale.updated_at
        }]
      end
      render :json => Hash[stats]
    end
  end
end

#updateObject



26
27
28
29
30
# File 'app/controllers/tolk/locales_controller.rb', line 26

def update
  @locale.translations_attributes = translation_params
  @locale.save
  redirect_to request.referrer
end

#updatedObject



36
37
38
39
# File 'app/controllers/tolk/locales_controller.rb', line 36

def updated
  @phrases = @locale.phrases_with_updated_translation(params[pagination_param])
  render :all
end