2018-02-09 21:28:27 +00:00
|
|
|
class I18nController < ApplicationController
|
|
|
|
before_action :authenticate!
|
|
|
|
|
|
|
|
def index
|
|
|
|
@site = find_site
|
|
|
|
|
|
|
|
redirect_to site_i18n_edit_path(@site)
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@site = find_site
|
|
|
|
@lang_from = I18n.locale.to_s
|
|
|
|
@lang_to = @site.config['i18n'].reject { |i| i == @lang_from }.sample
|
2018-02-19 19:33:28 +00:00
|
|
|
@lang_to = 'ar'
|
2018-02-09 21:28:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@site = find_site
|
2018-02-19 19:33:28 +00:00
|
|
|
# No usamos params porque nos obliga a hacer una lista blanca de
|
|
|
|
# todos los parámetros que queremos, pero no tenemos forma aun de
|
|
|
|
# pasarse a permit un array de todas las keys y sus tipos en base al
|
|
|
|
# idioma que ya existe
|
|
|
|
p = request.parameters[:i18n][:ar]
|
|
|
|
i = JekyllI18n.new(site: @site, lang: :ar, attributes: p)
|
|
|
|
|
|
|
|
if i.save
|
|
|
|
redirect_to site_path(@site)
|
|
|
|
else
|
|
|
|
render 'i18n/edit'
|
|
|
|
end
|
2018-02-09 21:28:27 +00:00
|
|
|
end
|
|
|
|
end
|