diff --git a/app/views/i18n/_form.haml b/app/views/i18n/_form.haml index c75177e..af3cb50 100644 --- a/app/views/i18n/_form.haml +++ b/app/views/i18n/_form.haml @@ -1,34 +1,55 @@ -= form_tag site_i18n_edit_path(@site), method: :get, class: 'form-inline' do - %h1 - - 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 +.row + .col + = form_tag site_i18n_edit_path(@site), method: :get, class: 'form-inline' do + %h1 + - 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') + = 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 - .form-group - = submit_tag t('i18n.save'), class: 'btn btn-success' - = render 'i18n/recursive', data: @site.data.dig(@lang_from), superkeys: [] +.row + .col + %ul.list-group + - @site.data.dig(@lang_from).each_pair do |section, content| + %li.list-group-item.align-items-center.justify-content-between.d-flex + %a{href: "##{section}", + title: t('help.i18n.toc'), + data: { turbolinks: 'false', toggle: 'tooltip' }}= t("help.i18n.#{section}") + -# %span.badge.badge-secondary.badge-pill{data: { toggle: 'tooltip' }, + title: t('help.i18n.count') } + - if content.is_a? String + = 1 + - elsif content.is_a? Array + = content.count + - elsif content.is_a? Hash + = content.map(&:count).inject(&:+) + .col - .form-group - = submit_tag t('i18n.save'), class: 'btn btn-success' + = form_tag site_i18n_path(@site), method: :post, class: 'form' do + = hidden_field 'i18n', 'lang_to', value: @lang_to + .form-group + = 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/app/views/i18n/_recursive.haml b/app/views/i18n/_recursive.haml index 6c99250..b54f4be 100644 --- a/app/views/i18n/_recursive.haml +++ b/app/views/i18n/_recursive.haml @@ -1,8 +1,14 @@ +- previous_key ||= '' - data.each_pair do |key, value| - keys = [superkeys, key].flatten + - unless keys.first == previous_key + %h2{id: keys.first} + = t("help.i18n.#{keys.first}") - if value.is_a? String = render 'i18n/text_field', keys: keys, value: value - elsif value.is_a? Hash - = render 'i18n/recursive', data: value, superkeys: keys + = render 'i18n/recursive', data: value, superkeys: keys, + previous_key: keys.first - elsif value.is_a? Array - = render 'i18n/recursive_array', data: value, superkeys: keys + = render 'i18n/recursive_array', data: value, superkeys: keys, + previous_key: keys.first diff --git a/app/views/i18n/_recursive_array.haml b/app/views/i18n/_recursive_array.haml index 7db0e36..e315e06 100644 --- a/app/views/i18n/_recursive_array.haml +++ b/app/views/i18n/_recursive_array.haml @@ -1,8 +1,14 @@ +- previous_key ||= '' - data.each_with_index do |value, i| - keys = [superkeys, i].flatten + - unless keys.first == previous_key + %h2{id: keys.first} + = t("help.i18n.#{keys.first}") - if value.is_a? String = render 'i18n/text_field', keys: keys, value: value - elsif value.is_a? Hash - = render 'i18n/recursive', data: value, superkeys: keys + = render 'i18n/recursive', data: value, superkeys: keys, + previous_key: keys.first - elsif value.is_a? Array - = render 'i18n/recursive_array', data: value, superkeys: keys + = render 'i18n/recursive_array', data: value, superkeys: keys, + previous_key: keys.first diff --git a/app/views/i18n/edit.haml b/app/views/i18n/edit.haml index 66655c7..0eee60f 100644 --- a/app/views/i18n/edit.haml +++ b/app/views/i18n/edit.haml @@ -6,6 +6,4 @@ t('i18n.index'), t('i18n.edit')] -.row - .col - = render 'i18n/form' += render 'i18n/form' diff --git a/config/locales/en.yml b/config/locales/en.yml index 4a361fe..2bccb5a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -11,6 +11,31 @@ en: 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." + count: 'This is the amount of texts.' + toc: 'Jump to this section' + meta: 'Metadata' + navegacion: 'Navigation' + inicio: 'Home' + volver: 'Back' + entrar: 'Enter' + cerrar: 'Close' + anchor: 'Internal links' + nav: 'Menu' + nav-lang: 'Language menu' + modulos: 'Modules' + header: 'Header' + sobre: 'About' + metodologia: 'Methodology' + planeando_recursos: 'Planning resources' + rutas: 'Agendas' + complementarios: 'Materials' + recursos: 'Resources' + contacta: 'Contact us' + agradecimientos: 'Acknowledgments' + sesion: 'Sessions' + sesiones: 'Sessions' + anexo: 'Appendix' + simple: 'Simple' 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 d076c83..df3d83e 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -12,6 +12,31 @@ es: 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.' + count: 'Esta es la cantidad de textos.' + toc: 'Saltar hasta esta sección' + meta: 'Metadata' + navegacion: 'Navegación' + inicio: 'Inicio' + volver: 'Volver' + entrar: 'Entrar' + cerrar: 'Cerrar' + anchor: 'Links internos' + nav: 'Menú' + nav-lang: 'Menú de idiomas' + modulos: 'Módulos' + header: 'Portada' + sobre: 'Acerca' + metodologia: 'Metodología' + planeando_recursos: 'Planeando recursos' + rutas: 'Rutas' + complementarios: 'Materiales complementarios' + recursos: 'Recursos' + contacta: 'Contacta' + agradecimientos: 'Agradecimientos' + sesion: 'Sesiones' + sesiones: 'Sesiones' + anexo: 'Anexo' + simple: 'Simple' sites: index: 'Este es el listado de sitios que puedes editar.' edit_translations: 'Puedes editar los textos que salen en tu sitio