From 9271c969a00705b8bb8add54ddde92d337404135 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Wed, 25 Jan 2023 12:06:44 +0000 Subject: [PATCH] feat: allow translation text and title text to display currency formatting even when not a log field --- app/helpers/interruption_screen_helper.rb | 4 ++-- .../sales/pages/about_price_shared_ownership_value_check.rb | 1 + config/locales/en.yml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/helpers/interruption_screen_helper.rb b/app/helpers/interruption_screen_helper.rb index 7731d9425..d4034c01e 100644 --- a/app/helpers/interruption_screen_helper.rb +++ b/app/helpers/interruption_screen_helper.rb @@ -10,7 +10,7 @@ module InterruptionScreenHelper else lettings_log.public_send(argument["key"]) end - translation_params[argument["i18n_template"].to_sym] = value + translation_params[argument["i18n_template"].to_sym] = argument["prefix"] == "£" ? "£#{ActionController::Base.helpers.number_to_currency(value, delimiter: ',', format: '%n')}" : value end begin @@ -33,7 +33,7 @@ module InterruptionScreenHelper else lettings_log.public_send(argument["key"]) end - translation_params[argument["i18n_template"].to_sym] = value + translation_params[argument["i18n_template"].to_sym] = argument["prefix"] == "£" ? "£#{ActionController::Base.helpers.number_to_currency(value, delimiter: ',', format: '%n')}" : value end I18n.t(title_text["translation"], **translation_params).to_s end diff --git a/app/models/form/sales/pages/about_price_shared_ownership_value_check.rb b/app/models/form/sales/pages/about_price_shared_ownership_value_check.rb index 3fcefcea7..90862a5b5 100644 --- a/app/models/form/sales/pages/about_price_shared_ownership_value_check.rb +++ b/app/models/form/sales/pages/about_price_shared_ownership_value_check.rb @@ -24,6 +24,7 @@ class Form::Sales::Pages::AboutPriceSharedOwnershipValueCheck < ::Form::Page "key" => "purchase_price_soft_min_or_soft_max", "label" => false, "i18n_template" => "soft_min_or_soft_max", + "prefix" => "£", }, { "key" => "purchase_price_min_or_max_text", diff --git a/config/locales/en.yml b/config/locales/en.yml index fafde38b1..e757e30f7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -435,7 +435,7 @@ en: hint_text: "The maximum rent expected for this type of property in this local authority is £%{soft_max_for_period}" purchase_price: title_text: "You told us the purchase price is %{value}" - hint_text: "The %{min_or_max} purchase price expected for this type of property in this local authority is £%{soft_min_or_soft_max}" + hint_text: "The %{min_or_max} purchase price expected for this type of property in this local authority is %{soft_min_or_soft_max}" retirement: min: title: "You told us this person is under %{age} and retired"