From d6b113209527d58dae6d5819f51d09be33aca173 Mon Sep 17 00:00:00 2001 From: ivo Date: Thu, 5 Sep 2024 13:43:15 +0100 Subject: [PATCH] feat: I18n translation function call on templates hardcoded texts --- app/controllers/submissions_controller.rb | 4 +- .../templates_restore_controller.rb | 2 +- app/javascript/template_builder/i18n.js | 128 ++++++++++++++- app/views/api_settings/index.html.erb | 6 +- app/views/dashboard/_toggle_view.html.erb | 2 +- app/views/shared/_clipboard_copy.html.erb | 4 +- app/views/shared/_settings_nav.html.erb | 2 +- app/views/submissions/_detailed_form.html.erb | 4 +- app/views/submissions/_email_form.html.erb | 6 +- app/views/submissions/_phone_form.html.erb | 4 +- app/views/submissions/_send_email.html.erb | 4 +- .../submissions/_submitters_order.html.erb | 4 +- app/views/submissions/show.html.erb | 8 +- app/views/submissions_archived/index.html.erb | 2 +- .../submissions_dashboard/index.html.erb | 8 +- app/views/submit_form/_docuseal_logo.html.erb | 6 +- app/views/templates/_dropzone.html.erb | 6 +- app/views/templates/_submission.html.erb | 30 ++-- app/views/templates/_title.html.erb | 8 +- app/views/templates/new.html.erb | 8 +- app/views/templates/show.html.erb | 18 +-- app/views/templates_archived/index.html.erb | 4 +- .../index.html.erb | 8 +- app/views/templates_dashboard/index.html.erb | 6 +- .../templates_form_preview/show.html.erb | 2 +- app/views/templates_uploads/show.html.erb | 2 +- app/views/users/index.html.erb | 2 +- config/locales/en.yml | 149 +++++++++++++++++- 28 files changed, 349 insertions(+), 88 deletions(-) diff --git a/app/controllers/submissions_controller.rb b/app/controllers/submissions_controller.rb index ceba45f6a..0f7680177 100644 --- a/app/controllers/submissions_controller.rb +++ b/app/controllers/submissions_controller.rb @@ -57,13 +57,13 @@ def destroy if params[:permanently].present? @submission.destroy! - 'Submission has been removed' + t('submission_has_been_removed') else @submission.update!(archived_at: Time.current) SendSubmissionArchivedWebhookRequestJob.perform_async('submission_id' => @submission.id) - 'Submission has been archived' + t('submission_has_been_archived') end redirect_back(fallback_location: template_path(@submission.template), notice:) diff --git a/app/controllers/templates_restore_controller.rb b/app/controllers/templates_restore_controller.rb index 2d1f80cf4..312e4ae5e 100644 --- a/app/controllers/templates_restore_controller.rb +++ b/app/controllers/templates_restore_controller.rb @@ -6,6 +6,6 @@ class TemplatesRestoreController < ApplicationController def create @template.update!(archived_at: nil) - redirect_to template_path(@template), notice: 'Template has been unarchived' + redirect_to template_path(@template), notice: t('template_has_been_unarchived') end end diff --git a/app/javascript/template_builder/i18n.js b/app/javascript/template_builder/i18n.js index 33bfc4b5a..102716ff3 100644 --- a/app/javascript/template_builder/i18n.js +++ b/app/javascript/template_builder/i18n.js @@ -117,7 +117,131 @@ const en = { custom: 'Custom', numbers_only: 'Numbers only', letters_only: 'Letters only', - regexp_validation: 'Regexp validation' + regexp_validation: 'Regexp validation', + save_and_preview: 'Save and Preview' } -export { en } +const ptPT = { + editable: 'Editável', + search_field: 'Campo de pesquisa', + field_not_found: 'Campo não encontrado', + clear: 'Limpar', + align: 'Alinhar', + add_all_required_fields_to_continue: 'Adicione todos os campos obrigatórios para continuar', + uploaded_pdf_contains_form_fields_keep_or_remove_them: 'O PDF carregado contém campos de formulário. Manter ou remover?', + keep: 'Manter', + left: 'Esquerda', + heading: 'Cabeçalho', + validation: 'Validação', + add_blank_page: 'Adicionar página em branco', + right: 'Direita', + center: 'Centro', + description: 'Descrição', + display_title: 'Mostrar título', + with_logo: 'Com logotipo', + unchecked: 'Não marcado', + price: 'Preço', + type_value: 'Digite o valor', + equal: 'Igual', + not_equal: 'Diferente', + contains: 'Contém', + does_not_contain: 'Não contém', + not_empty: 'Não está vazio', + empty: 'Vazio', + select_field_: 'Selecione o campo...', + select_value_: 'Selecione o valor...', + remove_condition: 'Remover condição', + add_condition: 'Adicionar condição', + are_you_sure: 'Tem a certeza?', + sign_yourself: 'Assine você mesmo', + set_signing_date: 'Definir data de assinatura', + signing_date: 'Data de assinatura', + send: 'Enviar', + remove: 'Remover', + edit: 'Editar', + settings: 'Definições', + up: 'Cima', + down: 'Baixo', + checked: 'Marcado', + save: 'Guardar', + cancel: 'Cancelar', + any: 'Qualquer', + drawn: 'Desenhado', + formula: 'Fórmula', + typed: 'Digitado', + draw_field_on_the_document: 'Desenhar campo {field} no documento', + click_to_upload: 'Clique para carregar', + or_drag_and_drop_files: 'ou arraste e solte os ficheiros', + uploading: 'A carregar', + processing_: 'A processar...', + add_pdf_documents_or_images: 'Adicionar documentos PDF ou imagens', + add_documents_or_images: 'Adicionar documentos ou imagens', + required: 'Obrigatório', + default_value: 'Valor padrão', + format: 'Formato', + read_only: 'Apenas leitura', + page: 'Página', + draw_new_area: 'Desenhar nova área', + copy_to_all_pages: 'Copiar para todas as páginas', + add_option: 'Adicionar opção', + option: 'Opção', + condition: 'Condição', + first_party: 'Primeira Parte', + second_party: 'Segunda Parte', + third_party: 'Terceira Parte', + fourth_party: 'Quarta Parte', + fifth_party: 'Quinta Parte', + sixth_party: 'Sexta Parte', + seventh_party: 'Sétima Parte', + eighth_party: 'Oitava Parte', + ninth_party: 'Nona Parte', + tenth_party: 'Décima Parte', + eleventh_party: 'Décima Primeira Parte', + twelfth_party: 'Décima Segunda Parte', + thirteenth_party: 'Décima Terceira Parte', + fourteenth_party: 'Décima Quarta Parte', + fifteenth_party: 'Décima Quinta Parte', + sixteenth_party: 'Décima Sexta Parte', + seventeenth_party: 'Décima Sétima Parte', + eighteenth_party: 'Décima Oitava Parte', + nineteenth_party: 'Décima Nona Parte', + twentieth_party: 'Vigésima Parte', + draw: 'Desenhar', + add: 'Adicionar', + or_add_field_without_drawing: 'Ou adicionar campo sem desenhar', + text: 'Texto', + number: 'Número', + signature: 'Assinatura', + initials: 'Iniciais', + date: 'Data', + image: 'Imagem', + file: 'Ficheiro', + select: 'Selecionar', + checkbox: 'Caixa de seleção', + multiple: 'Múltiplo', + radio: 'Rádio', + cells: 'Células', + stamp: 'Carimbo', + payment: 'Pagamento', + phone: 'Telefone', + field: 'Campo', + group: 'Grupo', + draw_a_text_field_on_the_page_with_a_mouse: 'Desenhe um campo de texto na página com o rato', + draw_field: 'Desenhar Campo {field}', + replace: 'Substituir', + uploading_: 'A carregar...', + add_document: 'Adicionar Documento', + none: 'Nenhum', + ssn: 'NIF', + ein: 'NIPC', + email: 'Email', + url: 'URL', + zip: 'Código Postal', + custom: 'Personalizado', + numbers_only: 'Apenas números', + letters_only: 'Apenas letras', + regexp_validation: 'Validação por Regexp', + save_and_preview: 'Gravar e Prever' +} + +export { en, ptPT } diff --git a/app/views/api_settings/index.html.erb b/app/views/api_settings/index.html.erb index 0b9e1cfa5..2e9022953 100644 --- a/app/views/api_settings/index.html.erb +++ b/app/views/api_settings/index.html.erb @@ -48,7 +48,7 @@ ] }'<% end.to_str %> - <%= render 'shared/clipboard_copy', icon: 'copy', text:, class: 'btn btn-ghost text-white', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy', copied_title: 'Copied' %> + <%= render 'shared/clipboard_copy', icon: 'copy', text:, class: 'btn btn-ghost text-white', icon_class: 'w-6 h-6 text-white', copy_title: t('general_copy'), copied_title: t('general_copied') %>
<%= text %>
@@ -74,7 +74,7 @@ "emails": "<%= current_user.email.sub('@', '+test@') %>, <%= current_user.email.sub('@', '+test2@') %>" }'<% end.to_str %> - <%= render 'shared/clipboard_copy', icon: 'copy', text:, class: 'btn btn-ghost text-white', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy', copied_title: 'Copied' %> + <%= render 'shared/clipboard_copy', icon: 'copy', text:, class: 'btn btn-ghost text-white', icon_class: 'w-6 h-6 text-white', copy_title: t('general_copy'), copied_title: t('general_copied') %>
<%= text %>
@@ -96,7 +96,7 @@ <% text = capture do %>curl '<%= api_template_url(current_account.templates&.last || 1) %>' \ --header 'X-Auth-Token: <%= current_user.access_token.token %>'<% end.to_str %> - <%= render 'shared/clipboard_copy', icon: 'copy', text:, class: 'btn btn-ghost text-white', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy', copied_title: 'Copied' %> + <%= render 'shared/clipboard_copy', icon: 'copy', text:, class: 'btn btn-ghost text-white', icon_class: 'w-6 h-6 text-white', copy_title: t('general_copy'), copied_title: t('general_copied') %>
<%= text %>
diff --git a/app/views/dashboard/_toggle_view.html.erb b/app/views/dashboard/_toggle_view.html.erb index 53810f920..9a35edcfd 100644 --- a/app/views/dashboard/_toggle_view.html.erb +++ b/app/views/dashboard/_toggle_view.html.erb @@ -4,7 +4,7 @@ <%= svg_icon('layout_grid', class: 'w-6 h-6 stroke-2') %> - + diff --git a/app/views/shared/_clipboard_copy.html.erb b/app/views/shared/_clipboard_copy.html.erb index 1c9fdc25f..fbc6128f2 100644 --- a/app/views/shared/_clipboard_copy.html.erb +++ b/app/views/shared/_clipboard_copy.html.erb @@ -4,7 +4,7 @@ <%= svg_icon(local_assigns[:icon] || 'link', class: local_assigns[:icon_class] || 'w-6 h-6 text-white') %> <% if local_assigns[:copy_title_md] %> @@ -15,7 +15,7 @@