Class: LocaleNinja::LocalesController

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

Instance Method Summary collapse

Instance Method Details

#showObject



15
16
17
18
19
20
# File 'app/controllers/locale_ninja/locales_controller.rb', line 15

def show
  @locale = params[:locale]
  @branch_name = params[:branch_id]
  @source, @target = LocaleHelper.all_keys_for_locales(@client, [I18n.default_locale.to_s, @locale], branch: @branch_name)
  @translations = @target.zip(@source)
end

#updateObject



22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/locale_ninja/locales_controller.rb', line 22

def update
  @branch_name = params[:branch_id]
  translation_keys = params[:val].permit!.to_h.compact_blank
  yml = LocaleHelper.keys2yml(translation_keys)
  yml.each { |path, file| @client.push(path, file, branch: @branch_name) }
  @client.pull_request(@branch_name)
  flash[:success] = t('.success')

  redirect_to(branch_path(@branch_name))
end