refactor(attachment): extract i18n
This commit is contained in:
parent
2f84346ba3
commit
b110e58f2f
22 changed files with 72 additions and 24 deletions
|
@ -137,9 +137,9 @@ class Attachment::EditComponent < ApplicationComponent
|
|||
def error_message
|
||||
case
|
||||
when attachment.virus_scanner.infected?
|
||||
"Virus détecté, merci d’envoyer un autre fichier."
|
||||
t(".errors.virus_infected")
|
||||
when attachment.virus_scanner.corrupt?
|
||||
"Le fichier est corrompu, merci d’envoyer un autre fichier."
|
||||
t(".errors.corrupted_file")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
---
|
||||
en:
|
||||
max_file_size: "File size limit : %{max_file_size}."
|
||||
allowed_formats: "Supported formats : %{formats}"
|
||||
retry: Retry
|
||||
delete: Delete
|
||||
errors:
|
||||
uploading: "An error occurred while sending the file."
|
||||
virus_infected: "Virus detected, please send another file."
|
||||
corrupted_file: "The file is corrupted, please send another file."
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
---
|
||||
fr:
|
||||
max_file_size: "Taille maximale : %{max_file_size}."
|
||||
allowed_formats: "Formats supportés : %{formats}"
|
||||
retry: Ré-essayer
|
||||
delete: Supprimer
|
||||
errors:
|
||||
uploading: "Une erreur s’est produite pendant l’envoi du fichier."
|
||||
virus_infected: "Virus détecté, merci d’envoyer un autre fichier."
|
||||
corrupted_file: "Le fichier est corrompu, merci d’envoyer un autre fichier."
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
%div{ id: dom_id(attachment, :persisted_row) }
|
||||
.flex.flex-gap-2{ class: class_names("attachment-error": attachment.virus_scanner_error?) }
|
||||
- if user_can_destroy?
|
||||
= link_to('Supprimer', destroy_attachment_path, **remove_button_options, class: "fr-btn fr-btn--tertiary fr-btn--sm fr-icon-delete-line", title: "Supprimer le fichier #{attachment.filename}")
|
||||
= link_to(t('.delete'), destroy_attachment_path, **remove_button_options, class: "fr-btn fr-btn--tertiary fr-btn--sm fr-icon-delete-line", title: "Supprimer le fichier #{attachment.filename}")
|
||||
|
||||
.fr-py-1v
|
||||
- if downloadable?
|
||||
|
@ -21,8 +21,7 @@
|
|||
- if max_file_size.present?
|
||||
= t('.max_file_size', max_file_size: number_to_human_size(max_file_size))
|
||||
- if allowed_formats
|
||||
Formats supportés :
|
||||
= allowed_formats.join(', ')
|
||||
= t('.allowed_formats', formats: allowed_formats.join(', '))
|
||||
|
||||
|
||||
- if !as_multiple?
|
||||
|
@ -32,10 +31,10 @@
|
|||
%div{ data: poll_controller_options }
|
||||
- if attachment.created_at < 30.seconds.ago
|
||||
.fr-mt-2w
|
||||
= render partial: "attachments/pending_refresh", url: attachment_path
|
||||
= render Attachment::LongProcessingRefreshComponent.new(attachment: attachment)
|
||||
|
||||
.attachment-error.hidden
|
||||
%p.fr-error-text Une erreur s’est produite pendant l’envoi du fichier.
|
||||
%p.fr-error-text= t('.errors.uploading')
|
||||
= button_tag(**retry_button_options) do
|
||||
Ré-essayer
|
||||
= t(".retry")
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class Attachment::LongProcessingRefreshComponent < ApplicationComponent
|
||||
def initialize(attachment: nil)
|
||||
@attachment = attachment
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
en:
|
||||
reload: Reload
|
||||
explanation: Scanning for viruses and processing your attachment(s) takes longer than expected.
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
fr:
|
||||
reload: Recharger
|
||||
explanation: L’analyse antivirus et le traitement de votre ou de vos pièces jointes prend plus de temps que prévu.
|
|
@ -0,0 +1,5 @@
|
|||
= render Dsfr::CalloutComponent.new(title: nil) do |c|
|
||||
- c.with_body do
|
||||
= t(".explanation")
|
||||
- c.with_bottom do
|
||||
= button_tag t(".reload"), type: "button", class: "fr-btn", data: { action: 'click->turbo-poll#refresh' }
|
|
@ -12,4 +12,4 @@
|
|||
- if in_progress?
|
||||
%div{ data: poll_controller_options }
|
||||
- if in_progress_long?
|
||||
= render "attachments/pending_refresh", url: auto_attach_url
|
||||
= render Attachment::LongProcessingRefreshComponent.new
|
||||
|
|
|
@ -8,9 +8,9 @@ class Attachment::ProgressComponent < ApplicationComponent
|
|||
def progress_label
|
||||
case
|
||||
when attachment.virus_scanner.pending?
|
||||
"Analyse antivirus en cours…"
|
||||
t(".antivirus_pending")
|
||||
when attachment.watermark_pending?
|
||||
"Traitement en cours…"
|
||||
t(".watermark_pending")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
en:
|
||||
antivirus_pending: "Antivirus scanning in progress…"
|
||||
watermark_pending: "Processing in progress…"
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
fr:
|
||||
antivirus_pending: "Analyse antivirus en cours…"
|
||||
watermark_pending: "Traitement en cours…"
|
|
@ -12,9 +12,9 @@ class Attachment::ShowComponent < ApplicationComponent
|
|||
def error_message
|
||||
case
|
||||
when attachment.virus_scanner.infected?
|
||||
"Virus détecté, le téléchargement est bloqué."
|
||||
t(".errors.virus_infected")
|
||||
when attachment.virus_scanner.corrupt?
|
||||
"Le fichier est corrompu, le téléchargement est bloqué."
|
||||
t(".errors.corrupted_file")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
---
|
||||
en:
|
||||
virus_not_analyzed: this file has not been scanned by our antivirus, download it with care
|
||||
errors:
|
||||
virus_infected: Virus detected, download is blocked.
|
||||
corrupted_file: The file is corrupted, the download is blocked.
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
---
|
||||
fr:
|
||||
virus_not_analyzed: ce fichier n’a pas été analysé par notre antivirus, téléchargez-le avec précaution
|
||||
errors:
|
||||
virus_infected: "Virus détecté, le téléchargement est bloqué."
|
||||
corrupted_file: "Le fichier est corrompu, le téléchargement est bloqué."
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
= render Dsfr::DownloadComponent.new(attachment: attachment) do |c|
|
||||
- if !attachment.virus_scanner.started?
|
||||
- c.right do
|
||||
(ce fichier n’a pas été analysé par notre antivirus, téléchargez-le avec précaution)
|
||||
= "(#{t(".virus_not_analyzed")})"
|
||||
|
||||
- else
|
||||
.attachment-filename.fr-mb-1w.fr-mr-1w= attachment.filename.to_s
|
||||
|
|
|
@ -11,6 +11,6 @@ class Dsfr::DownloadComponent < ApplicationComponent
|
|||
end
|
||||
|
||||
def title
|
||||
"Télécharger le fichier #{attachment.filename}"
|
||||
t(".title", filename: attachment.filename.to_s)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
en:
|
||||
title: "Download file %{filename}"
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
fr:
|
||||
title: "Télécharger le fichier %{filename}"
|
|
@ -1,6 +0,0 @@
|
|||
= render Dsfr::CalloutComponent.new(title: nil) do |c|
|
||||
- c.with_body do
|
||||
L’analyse antivirus de votre ou de vos pièces jointes prend plus de temps que prévu.
|
||||
- c.with_bottom do
|
||||
= button_tag "Rafraîchir le traitement", type: "button", class: "fr-btn", data: { action: 'click->turbo-poll#refresh' }
|
||||
|
|
@ -28,7 +28,7 @@ RSpec.describe Attachment::EditComponent, type: :component do
|
|||
end
|
||||
|
||||
it 'renders allowed formats' do
|
||||
expect(subject).to have_content(/Formats supportés :\s+jpeg, png/)
|
||||
expect(subject).to have_content(/Formats supportés : jpeg, png/)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -128,7 +128,7 @@ RSpec.describe Attachment::EditComponent, type: :component do
|
|||
end
|
||||
|
||||
it 'renders a refresh button' do
|
||||
expect(subject).to have_button("Rafraîchir")
|
||||
expect(subject).to have_button("Recharger")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ RSpec.describe Attachment::MultipleComponent, type: :component do
|
|||
context "process is taking longer than expected" do
|
||||
let(:created_at) { 5.minutes.ago }
|
||||
it 'renders a refresh button' do
|
||||
expect(subject).to have_button("Rafraîchir")
|
||||
expect(subject).to have_button("Recharger")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue