From f3b6717b23ee4010caf7abe2250f3e776be16519 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 26 Feb 2018 17:32:33 -0300 Subject: [PATCH] traducir o editar --- app/controllers/i18n_controller.rb | 2 +- app/views/i18n/_form.haml | 34 ++++++++++++++++++++++-------- config/locales/en.yml | 5 +++++ config/locales/es.yml | 9 ++++++++ 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/app/controllers/i18n_controller.rb b/app/controllers/i18n_controller.rb index b7298ea3..72c3b9bf 100644 --- a/app/controllers/i18n_controller.rb +++ b/app/controllers/i18n_controller.rb @@ -10,7 +10,7 @@ class I18nController < ApplicationController def edit @site = find_site @lang_from = params.fetch(:from, I18n.locale.to_s) - @lang_to = params.fetch(:to, I18n.available_locales.sample.to_s) + @lang_to = params.fetch(:to, @lang_from) @options = I18n.available_locales.map do |lang| [ t("i18n.#{lang.to_s}"), lang.to_s ] end diff --git a/app/views/i18n/_form.haml b/app/views/i18n/_form.haml index 5f2c630d..c75177e1 100644 --- a/app/views/i18n/_form.haml +++ b/app/views/i18n/_form.haml @@ -1,14 +1,27 @@ = form_tag site_i18n_edit_path(@site), method: :get, class: 'form-inline' do %h1 - = t('i18n.translating.from') - = select_tag 'from', - options_for_select(@options, @lang_from), - class: 'form-control' - = t('i18n.translating.to') - = select_tag 'to', - options_for_select(@options, @lang_to), - class: 'form-control' - = submit_tag t('i18n.change'), class: 'btn btn-info', name: nil + - if @lang_from == @lang_to + = t('i18n.edit_same') + = select_tag 'from', + options_for_select(@options, @lang_from), + class: 'form-control' + = t('i18n.translate_into') + = select_tag 'to', + options_for_select(@options, @lang_to), + class: 'form-control' + = submit_tag t('i18n.translate'), class: 'btn btn-info', name: nil + - else + = t('i18n.translating.from') + = select_tag 'from', + options_for_select(@options, @lang_from), + class: 'form-control' + = t('i18n.translating.to') + = select_tag 'to', + options_for_select(@options, @lang_to), + class: 'form-control' + = submit_tag t('i18n.change'), class: 'btn btn-info', name: nil + += render 'layouts/help', help: t('help.i18n.index') = form_tag site_i18n_path(@site), method: :post, class: 'form' do = hidden_field 'i18n', 'lang_to', value: @lang_to @@ -16,3 +29,6 @@ = submit_tag t('i18n.save'), class: 'btn btn-success' = render 'i18n/recursive', data: @site.data.dig(@lang_from), superkeys: [] + + .form-group + = submit_tag t('i18n.save'), class: 'btn btn-success' diff --git a/config/locales/en.yml b/config/locales/en.yml index 8c146f3c..4a361fe3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -6,6 +6,11 @@ en: breadcrumbs: "What you see up here are the bread crumbs for this site. When you enter a new section, you will see the previous ones and also have a path for where you\'re standing." + i18n: + index: "Here you can edit your site's texts that don't belong to a + post, like its description, sections, buttons... If you change + languages up there in the title to be the same, you can edit them. + If they're different, you can translate from one into the other." sites: index: 'This is the list of sites you can edit.' edit_translations: "You can edit texts from your site other than diff --git a/config/locales/es.yml b/config/locales/es.yml index dd7fddfe..d076c83b 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -6,6 +6,12 @@ es: breadcrumbs: 'Lo que ves arriba son las migas de pan de este sitio. Cuando ingreses a una sección, podrás volver a las secciones anteriores y además tener una ruta de donde estás parada.' + i18n: + index: 'Aquí puedes editar todos los textos del sitio que no se + corresponden con artículos, como la descripción, secciones, textos + de botones... Si cambias los idiomas arriba para que coincidan, + puedes editar los textos en el mismo idioma. Si los idiomas no + coinciden, puedes traducirlos de uno a otro.' sites: index: 'Este es el listado de sitios que puedes editar.' edit_translations: 'Puedes editar los textos que salen en tu sitio @@ -71,8 +77,11 @@ es: i18n: index: 'Traducciones' edit: 'Editar textos y traducciones' + edit_same: 'Editar textos en' save: 'Guardar' + translate_into: '. Traducir a' change: 'Cambiar' + translate: 'Traducir' translating: from: 'Traduciendo desde' to: 'a'