From 3fca5f7338b057e32bc39aa2b2c3c0e10961194f Mon Sep 17 00:00:00 2001 From: Arthur Campbell Date: Fri, 3 Mar 2023 17:37:05 +0000 Subject: [PATCH] use built in rails methods of pluralising copy --- app/helpers/copy_helper.rb | 5 ----- app/models/form/sales/questions/buyer_previous.rb | 8 ++------ app/models/form/sales/questions/prevown.rb | 4 ++-- app/models/form/sales/questions/staircase_owned.rb | 4 ++-- config/locales/en.yml | 12 ++++++++++++ 5 files changed, 18 insertions(+), 15 deletions(-) delete mode 100644 app/helpers/copy_helper.rb diff --git a/app/helpers/copy_helper.rb b/app/helpers/copy_helper.rb deleted file mode 100644 index ebea85379..000000000 --- a/app/helpers/copy_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -module CopyHelper - def translate(key, pluralise_condition: false) - I18n.t(key, count: pluralise_condition ? 2 : 1) - end -end diff --git a/app/models/form/sales/questions/buyer_previous.rb b/app/models/form/sales/questions/buyer_previous.rb index d035d9d2f..15fe330f0 100644 --- a/app/models/form/sales/questions/buyer_previous.rb +++ b/app/models/form/sales/questions/buyer_previous.rb @@ -1,13 +1,9 @@ class Form::Sales::Questions::BuyerPrevious < ::Form::Question - include CopyHelper - def initialize(id, hsh, page, joint_purchase:) super(id, hsh, page) @id = "soctenant" - @check_answer_label = translate("check_answer_labels.soctenant", pluralise_condition: joint_purchase) - # @check_answer_label = I18n.t("check_answer_labels.soctenant", count: joint_purchase ? 2 : 1) - @header = translate("questions.soctenant", pluralise_condition: joint_purchase) - # @header = I18n.t("questions.soctenant", count: joint_purchase ? 2 : 1) + @check_answer_label = I18n.t("check_answer_labels.soctenant", count: joint_purchase ? 2 : 1) + @header = I18n.t("questions.soctenant", count: joint_purchase ? 2 : 1) @type = "radio" @answer_options = ANSWER_OPTIONS end diff --git a/app/models/form/sales/questions/prevown.rb b/app/models/form/sales/questions/prevown.rb index 50e6f081e..571e1af8f 100644 --- a/app/models/form/sales/questions/prevown.rb +++ b/app/models/form/sales/questions/prevown.rb @@ -2,8 +2,8 @@ class Form::Sales::Questions::Prevown < ::Form::Question def initialize(id, hsh, page, joint_purchase:) super(id, hsh, page) @id = "prevown" - @check_answer_label = "Buyer#{'s' if joint_purchase} previously owned a property" - @header = "#{joint_purchase ? 'Have any of the buyers' : 'Has the buyer'} previously owned a property?" + @check_answer_label = I18n.t("check_answer_labels.prevown", count: joint_purchase ? 2 : 1) + @header = I18n.t("questions.prevown", count: joint_purchase ? 2 : 1) @type = "radio" @answer_options = ANSWER_OPTIONS end diff --git a/app/models/form/sales/questions/staircase_owned.rb b/app/models/form/sales/questions/staircase_owned.rb index d05a421f0..a3596554e 100644 --- a/app/models/form/sales/questions/staircase_owned.rb +++ b/app/models/form/sales/questions/staircase_owned.rb @@ -2,8 +2,8 @@ class Form::Sales::Questions::StaircaseOwned < ::Form::Question def initialize(id, hsh, page, joint_purchase:) super(id, hsh, page) @id = "stairowned" - @check_answer_label = "Percentage the buyer#{'s' if joint_purchase} now own#{'s' unless joint_purchase} in total" - @header = "What percentage of the property #{joint_purchase ? 'do the buyers' : 'does the buyer'} now own in total?" + @check_answer_label = I18n.t("check_answer_labels.stairowned", count: joint_purchase ? 2 : 1) + @header = I18n.t("questions.stairowned", count: joint_purchase ? 2 : 1) @type = "numeric" @width = 5 @min = 0 diff --git a/config/locales/en.yml b/config/locales/en.yml index b38dce879..c3762e259 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -541,6 +541,12 @@ en: soctenant: one: "Was the buyer a private registered provider, housing association or local authority tenant immediately before this sale?" other: "Were any of the buyers private registered providers, housing association or local authority tenants immediately before this sale?" + prevown: + one: "Has the buyer previously owned a property?" + other: "Have any of the buyers previously owned a property?" + stairowned: + one: "What percentage of the property does the buyer now own in total?" + other: "What percentage of the property do the buyers now own in total?" hints: location: @@ -558,6 +564,12 @@ en: soctenant: one: "Buyer was a registered provider, housing association or local authority tenant immediately before this sale?" other: "Any buyers were registered providers, housing association or local authority tenants immediately before this sale?" + prevown: + one: "Buyer previously owned a property" + other: "Buyers previously owned a property" + stairowned: + one: "Percentage the buyer now owns in total" + other: "Percentage the buyers now own in total" warnings: location: