Localize crop approval status message partial (#5267)

Extract hardcoded English strings in app/views/crops/_approval_status_message.html.haml
into relative i18n calls and add translations across all standard locales
(en, de, es, fr, ja, zh). Add view specs to verify localized rendering.

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
Daniel O'Connorandgoogle-labs-jules[bot] authored and GitHub committed 2026-11-03 15:21:10 +10:30
1 parent b327c80c63
commit 7acb633070
8 files changed
+98 -5

No files matched your search

@@ -1,11 +1,10 @@
- if crop.pending?
.alert.alert-danger
%b This crop is currently pending approval.
%p This crop was requested by #{crop.requester} #{time_ago_in_words(crop.created_at)} ago.
%b= t('.pending_title')
%p= t('.requested_by', requester: crop.requester, time_ago: time_ago_in_words(crop.created_at))
- unless crop.request_notes.blank?
%p
Request notes: #{crop.request_notes}
%p= t('.request_notes', notes: crop.request_notes)
- if crop.rejected?
.alert.alert-danger
%b This crop was rejected for the following reason: #{crop.rejection_explanation}
%b= t('.rejected_message', reason: crop.rejection_explanation)
+5
View File
@@ -208,6 +208,11 @@ de:
published: Veröffentlicht
saved: Jobvorlage gespeichert.
crops:
approval_status_message:
pending_title: "Diese Kultur wartet derzeit auf Genehmigung."
rejected_message: "Diese Kultur wurde aus folgendem Grund abgelehnt: %{reason}"
request_notes: "Hinweise zur Anfrage: %{notes}"
requested_by: "Diese Kultur wurde vor %{time_ago} von %{requester} beantragt."
alternate_name_modal:
add_title: Weiteren Namen für %{crop} hinzufügen
cancel: Abbrechen
+5
View File
@@ -216,6 +216,11 @@ en:
published: Published
saved: Job template saved.
crops:
approval_status_message:
pending_title: "This crop is currently pending approval."
rejected_message: "This crop was rejected for the following reason: %{reason}"
request_notes: "Request notes: %{notes}"
requested_by: "This crop was requested by %{requester} %{time_ago} ago."
alternate_name_modal:
add_title: Add another name for %{crop}
cancel: Cancel
+5
View File
@@ -208,6 +208,11 @@ es:
published: Publicado
saved: Plantilla de trabajo guardada.
crops:
approval_status_message:
pending_title: "Este cultivo está pendiente de aprobación."
rejected_message: "Este cultivo fue rechazado por la siguiente razón: %{reason}"
request_notes: "Notas de la solicitud: %{notes}"
requested_by: "Este cultivo fue solicitado por %{requester} hace %{time_ago}."
alternate_name_modal:
add_title: Añadir otro nombre para %{crop}
cancel: Cancelar
+5
View File
@@ -208,6 +208,11 @@ fr:
published: Publié
saved: Modèle sauvegardé.
crops:
approval_status_message:
pending_title: "Cette culture est actuellement en attente d'approbation."
rejected_message: "Cette culture a été rejetée pour la raison suivante : %{reason}"
request_notes: "Notes de la demande : %{notes}"
requested_by: "Cette culture a été demandée par %{requester} il y a %{time_ago}."
alternate_name_modal:
add_title: Ajouter un autre nom pour %{crop}
cancel: Annuler
+5
View File
@@ -1,6 +1,11 @@
---
ja:
crops:
approval_status_message:
pending_title: "この作物は現在承認待ちです。"
rejected_message: "この作物は次の理由で却下されました: %{reason}"
request_notes: "リクエストのメモ: %{notes}"
requested_by: "この作物は %{time_ago}前に %{requester} によってリクエストされました。"
alternate_name_modal:
add_title: '%{crop}の別名を追加'
cancel: キャンセル
+5
View File
@@ -208,6 +208,11 @@ zh:
published: 已发表
saved: 作业模板已保存。
crops:
approval_status_message:
pending_title: "该作物目前正在等待审核。"
rejected_message: "该作物因以下原因被拒绝:%{reason}"
request_notes: "请求备注:%{notes}"
requested_by: "该作物由 %{requester} 在 %{time_ago}前请求添加。"
alternate_name_modal:
add_title: 为%{crop}添加别名
cancel: 取消
@@ -0,0 +1,64 @@
# frozen_string_literal: true
require 'rails_helper'
describe 'crops/_approval_status_message' do
subject { rendered }
context 'when crop is pending without request notes' do
let(:crop) { build_stubbed(:crop_request, request_notes: nil) }
before do
render partial: 'crops/approval_status_message', locals: { crop: }
end
it 'renders the localized pending title' do
expect(rendered).to have_content(I18n.t('crops.approval_status_message.pending_title'))
end
it 'renders the localized requester message' do
expected_text = I18n.t(
'crops.approval_status_message.requested_by',
requester: crop.requester,
time_ago: time_ago_in_words(crop.created_at)
)
expect(rendered).to have_content(expected_text)
end
end
context 'when crop is pending with request notes' do
let(:crop) { build_stubbed(:crop_request, request_notes: 'Need this for my garden.') }
before do
render partial: 'crops/approval_status_message', locals: { crop: }
end
it 'renders the localized pending title' do
expect(rendered).to have_content(I18n.t('crops.approval_status_message.pending_title'))
end
it 'renders the localized request notes' do
expected_text = I18n.t(
'crops.approval_status_message.request_notes',
notes: crop.request_notes
)
expect(rendered).to have_content(expected_text)
end
end
context 'when crop is rejected' do
let(:crop) { build_stubbed(:rejected_crop, reason_for_rejection: 'not edible') }
before do
render partial: 'crops/approval_status_message', locals: { crop: }
end
it 'renders the localized rejection message' do
expected_text = I18n.t(
'crops.approval_status_message.rejected_message',
reason: crop.rejection_explanation
)
expect(rendered).to have_content(expected_text)
end
end
end