Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: I18n translation function call on templates hardcoded texts #356

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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:)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/templates_restore_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
128 changes: 126 additions & 2 deletions app/javascript/template_builder/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
6 changes: 3 additions & 3 deletions app/views/api_settings/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
]
}'<% end.to_str %>
<span class="top-0 right-0 absolute">
<%= 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') %>
</span>
<pre data-prefix="$"><code class="overflow-hidden w-full"><%= text %></code></pre>
</div>
Expand All @@ -74,7 +74,7 @@
"emails": "<%= current_user.email.sub('@', '+test@') %>, <%= current_user.email.sub('@', '+test2@') %>"
}'<% end.to_str %>
<span class="top-0 right-0 absolute">
<%= 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') %>
</span>
<pre data-prefix="$"><code class="overflow-hidden w-full"><%= text %></code></pre>
</div>
Expand All @@ -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 %>
<span class="top-0 right-0 absolute">
<%= 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') %>
</span>
<pre data-prefix="$"><code class="overflow-hidden w-full"><%= text %></code></pre>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/dashboard/_toggle_view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<%= svg_icon('layout_grid', class: 'w-6 h-6 stroke-2') %>
</button>
</toggle-cookies>
<toggle-cookies data-value="submissions" data-key="dashboard_view" class="sm:tooltip tooltip-top" data-tip="Submissions">
<toggle-cookies data-value="submissions" data-key="dashboard_view" class="sm:tooltip tooltip-top" data-tip="<%= t('submissions') %>">
<button class="<%= local_assigns[:selected] == 'submissions' ? 'btn btn-neutral !rounded-lg btn-square !p-0 hover:text-neutral-300 !btn-sm !h-8 !w-9' : 'btn !border !rounded-lg btn-square !p-0 !btn-sm !h-8 !w-9 disabled:btn-neutral' %>">
<%= svg_icon('layout_list', class: 'w-6 h-6 stroke-2') %>
</button>
Expand Down
4 changes: 2 additions & 2 deletions app/views/shared/_clipboard_copy.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<span class="peer-checked:hidden flex items-center space-x-2">
<%= svg_icon(local_assigns[:icon] || 'link', class: local_assigns[:icon_class] || 'w-6 h-6 text-white') %>
<span class="hidden md:inline">
<%= local_assigns[:copy_title] || 'Copy' %>
<%= local_assigns[:copy_title] || t('general_copy') %>
</span>
<% if local_assigns[:copy_title_md] %>
<span class="inline md:hidden">
Expand All @@ -15,7 +15,7 @@
<span class="hidden peer-checked:flex items-center space-x-2">
<%= svg_icon(local_assigns[:copied_icon] || 'clipboard_copy', class: local_assigns[:icon_class] || 'w-6 h-6 text-white') %>
<span class="hidden md:inline">
<%= local_assigns[:copied_title] || 'Copied' %>
<%= local_assigns[:copied_title] || t('general_copied') %>
</span>
<% if local_assigns[:copied_title_md] %>
<span class="inline md:hidden">
Expand Down
2 changes: 1 addition & 1 deletion app/views/shared/_settings_nav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<menu-active>
<ul class="menu px-0">
<li class="menu-title py-0 !bg-transparent mb-3 -mt-5"><a href="<%= '/' %>" class="!bg-transparent !text-neutral font-medium">&larr; Back</a></li>
<li class="menu-title py-0 !bg-transparent"><span class="!bg-transparent">Settings</span></li>
<li class="menu-title py-0 !bg-transparent"><span class="!bg-transparent"><%= t('settings') %></span></li>
<li></li>
<li>
<%= link_to 'Profile', settings_profile_index_path, class: 'text-base hover:bg-base-300' %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/submissions/_detailed_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<% if params[:selfsign].blank? %>
<a href="#" class="btn btn-primary btn-sm w-full flex items-center justify-center" data-action="click:dynamic-list#addItem">
<%= svg_icon('user_plus', class: 'w-4 h-4 stroke-2') %>
<span>Add New</span>
<span><%= t('general_add')+' '+t('general_new') %></span>
</a>
<% end %>
</dynamic-list>
Expand All @@ -54,6 +54,6 @@
<%= render 'send_sms', f: %>
</div>
<div class="form-control">
<%= f.button button_title(title: 'Add Recipients'), class: 'base-button' %>
<%= f.button button_title(title: t('submissions_add_recipients')), class: 'base-button' %>
</div>
<% end %>
6 changes: 3 additions & 3 deletions app/views/submissions/_email_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<emails-textarea data-bulk-enabled="<%= Docuseal.demo? || !Docuseal.multitenant? || can?(:manage, :bulk_send) %>" data-limit="<%= Docuseal.multitenant? ? (can?(:manage, :bulk_send) ? 40 : 1) : nil %>">
<submitters-autocomplete data-field="email" class="block relative">
<autoresize-textarea>
<%= f.text_area :emails, required: true, class: 'base-textarea w-full !text-lg', placeholder: 'Type emails here...', rows: 2 %>
<%= f.text_area :emails, required: true, class: 'base-textarea w-full', placeholder: t('submissions_type_emails')+'...', rows: 2 %>
</autoresize-textarea>
</submitters-autocomplete>
</emails-textarea>
Expand Down Expand Up @@ -41,7 +41,7 @@
<% if params[:selfsign].blank? %>
<a href="#" class="btn btn-primary btn-sm w-full flex items-center justify-center" data-action="click:dynamic-list#addItem">
<%= svg_icon('user_plus', class: 'w-4 h-4 stroke-2') %>
<span>Add New</span>
<span><%= t('submissions_add_new') %></span>
</a>
<% end %>
</dynamic-list>
Expand All @@ -52,7 +52,7 @@
</div>
<div class="form-control">
<%= content_for(:submit_button) || capture do %>
<%= f.button button_title(title: 'Add Recipients'), class: 'base-button' %>
<%= f.button button_title(title: t('submissions_add_recipients')), class: 'base-button' %>
<% end %>
</div>
<% end %>
4 changes: 2 additions & 2 deletions app/views/submissions/_phone_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<% if params[:selfsign].blank? %>
<a href="#" class="btn btn-primary btn-sm w-full flex items-center justify-center" data-action="click:dynamic-list#addItem">
<%= svg_icon('user_plus', class: 'w-4 h-4 stroke-2') %>
<span>Add New</span>
<span><%= t('general_add')+' '+t('general_new') %></span>
</a>
<% end %>
</dynamic-list>
Expand All @@ -59,6 +59,6 @@
<%= render 'send_sms', f: %>
</div>
<div class="form-control">
<%= f.button button_title(title: 'Add Recipients'), class: 'base-button' %>
<%= f.button button_title(title: t('general_add')+' '+t('recipients')), class: 'base-button' %>
</div>
<% end %>
4 changes: 2 additions & 2 deletions app/views/submissions/_send_email.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
<div class="flex justify-between items-center">
<%= f.label :send_email, for: uuid = SecureRandom.uuid, class: 'flex items-center cursor-pointer' do %>
<%= f.check_box :send_email, id: uuid, class: 'base-checkbox', disabled: !can_send_emails, checked: can_send_emails %>
<span class="label">Send emails</span>
<span class="label"><%= t('submissions_send_emails') %></span>
<% end %>
<div>
<% if can_send_emails %>
<label>
<%= f.check_box :is_custom_message, onchange: "[this.form.querySelector('#message_field').classList.toggle('hidden', !event.currentTarget.checked)]", checked: false, class: 'hidden peer' %>
<span class="link peer-checked:hidden">Edit message</span>
<span class="link peer-checked:hidden"><%= t('submissions_edit_message') %></span>
</label>
<% end %>
<%= render 'email_stats' %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/submissions/_submitters_order.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<div class="form-control">
<%= f.label :preserve_order, for: uuid = SecureRandom.uuid, class: 'flex items-center cursor-pointer' do %>
<%= f.check_box :preserve_order, id: uuid, class: 'base-checkbox', checked: template.submissions.last&.submitters_order.in?(['preserved', nil]) %>
<span class="label">Preserve order</span>
<span class="tooltip" data-tip="When checked, notifications will be sent to the second party once the form is completed by the previous party. Uncheck this option to send notifications to all parties simultaneously right away.">
<span class="label"><%= t('submissions_preserve_order') %></span>
<span class="tooltip" data-tip="<%= t('submissions_preserve_order_hint') %>">
<%= svg_icon('info_circle', class: 'w-4 h-4') %>
</span>
<% end %>
Expand Down
10 changes: 5 additions & 5 deletions app/views/submissions/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<% end %>
</div>
<% elsif @submission.submitters.to_a.size == 1 && [email protected]? && [email protected]_a.first.declined_at? %>
<%= render 'shared/clipboard_copy', text: submit_form_url(slug: @submission.submitters.to_a.first.slug), class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: 'Copy Share Link', copied_title: 'Copied to Clipboard' %>
<%= render 'shared/clipboard_copy', text: submit_form_url(slug: @submission.submitters.to_a.first.slug), class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: t('copy_share_link'), copied_title: t('copied_to_clipboard') %>
<% end %>
</div>
</div>
Expand Down Expand Up @@ -146,9 +146,9 @@
<% if submitter&.declined_at? %>
Declined on <%= l(submitter.declined_at.in_time_zone(@submission.account.timezone), format: :short, locale: @submission.account.locale) %>
<% elsif submitter %>
<%= submitter.completed_at? ? l(submitter.completed_at.in_time_zone(@submission.account.timezone), format: :long, locale: @submission.account.locale) : 'Not completed yet' %>
<%= submitter&.completed_at? ? l(submitter.completed_at.in_time_zone(@submission.account.timezone), format: :long, locale: @submission.account.locale) : t('submissions_not_completed_yet') %>
<% else %>
Not invited yet
t('submissions_not_invited_yet')
<% end %>
</span>
</div>
Expand All @@ -162,7 +162,7 @@
<% end %>
<% if signed_in? && submitter && submitter.email && !submitter.completed_at && [email protected]_at? && can?(:update, submitter) && Accounts.can_send_emails?(current_account) && [email protected]? && !submitter.declined_at? %>
<div class="mt-2 mb-1">
<%= button_to button_title(title: submitter.sent_at? ? 'Re-send Email' : 'Send Email', disabled_with: 'Sending'), submitter_send_email_index_path(submitter_slug: submitter.slug), class: 'btn btn-sm btn-primary w-full' %>
<%= button_to button_title(title: submitter.sent_at? ? 'Re-send Email' : t('submissions_send_email'), disabled_with: 'Sending'), submitter_send_email_index_path(submitter_slug: submitter.slug), class: 'btn btn-sm btn-primary w-full' %>
</div>
<% end %>
<% if signed_in? && submitter && submitter.phone && !submitter.completed_at && [email protected]_at? && can?(:update, submitter) && [email protected]? && !submitter.declined_at? %>
Expand All @@ -171,7 +171,7 @@
<% if signed_in? && submitter && !submitter.completed_at? && [email protected]_at? && can?(:create, submitter) && [email protected]? && !submitter.declined_at? %>
<div class="mt-2 mb-1">
<a class="btn btn-sm btn-primary w-full" target="_blank" href="<%= submit_form_path(slug: submitter.slug) %>">
Sign In-person
<%= t('submissions_sign_in_person') %>
</a>
</div>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/submissions_archived/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>
<div class="flex justify-between mb-4 items-center">
<div>
<h1 class="text-4xl font-bold md:block <%= 'hidden' if params[:q].present? %>">Submissions <span class="badge badge-outline badge-lg align-middle">Archived</span></h1>
<h1 class="text-4xl font-bold md:block <%= 'hidden' if params[:q].present? %>"><%= I18n.t('submissions') %> <span class="badge badge-outline badge-lg align-middle"><%= I18n.t('general_archive') %></span></h1>
</div>
<% if params[:q].present? || @pagy.pages > 1 %>
<%= render 'shared/search_input', placeholder: 'Search...' %>
Expand Down
8 changes: 5 additions & 3 deletions app/views/submissions_dashboard/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
<div class="mr-2">
<%= render 'dashboard/toggle_view', selected: 'submissions' %>
</div>
<h1 class="text-2xl md:text-3xl sm:text-4xl font-bold md:block <%= 'hidden' if params[:q].present? %>">Submissions</h1>
<h1 class="text-2xl md:text-3xl sm:text-4xl font-bold md:block <%= 'hidden' if params[:q].present? %>">
<%= I18n.t('submissions') %>
</h1>
</div>
<div class="flex space-x-2">
<% if params[:q].present? || @pagy.pages > 1 %>
Expand All @@ -17,15 +19,15 @@
</span>
<%= link_to new_template_path, class: 'white-button !border gap-2', data: { turbo_frame: :modal } do %>
<%= svg_icon('plus', class: 'w-6 h-6 stroke-2') %>
<span class="hidden md:block">Create</span>
<span class="hidden md:block"><%= I18n.t('general_create') %></span>
<% end %>
<% end %>
</div>
</div>
<% view_archived_html = capture do %>
<% if current_account.submissions.where.not(archived_at: nil).exists? %>
<div>
<a href="<%= submissions_archived_index_path %>" class="link text-sm">View Archived</a>
<a href="<%= submissions_archived_index_path %>" class="link text-sm"><%= I18n.t('general_view') %> <%= I18n.t('general_archive') %></a>
</div>
<% end %>
<% end %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/submit_form/_docuseal_logo.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a href="<%= root_path %>" class="mx-auto text-2xl md:text-3xl font-bold items-center flex space-x-3">
<%= render 'shared/logo', class: 'w-9 h-9 md:w-12 md:h-12' %>
<span><%= Docuseal.product_name %></span>
<a href="<%= root_path %>" class="mx-auto text-2xl md:text-3xl font-bold items-center flex space-x-3 my-4">
<%= render 'shared/logo', class: 'w-9 h-9 md:w-12 md:h-12 my-10' %>
<span><%# Docuseal.product_name %></span>
</a>
Loading