From 75b1c5ed0f912d38b0b4b3d5fffbdf45ebda00ac Mon Sep 17 00:00:00 2001 From: Alan Cornthwaite Date: Thu, 21 Aug 2025 10:19:49 +0930 Subject: [PATCH] Localise field labels This is the allow users of Content to easily change the label / legend text --- Gemfile.lock | 2 +- app/helpers/katalyst/content/editor_helper.rb | 28 +++++++++---------- config/locales/en.yml | 7 +++++ katalyst-content.gemspec | 2 +- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e8fb6b0..f4abfcd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - katalyst-content (3.0.0) + katalyst-content (3.0.1) active_storage_validations activerecord katalyst-govuk-formbuilder diff --git a/app/helpers/katalyst/content/editor_helper.rb b/app/helpers/katalyst/content/editor_helper.rb index b6ae055..d72c4c1 100644 --- a/app/helpers/katalyst/content/editor_helper.rb +++ b/app/helpers/katalyst/content/editor_helper.rb @@ -18,39 +18,39 @@ def content_editor_rich_text_attributes(attributes = {}) end module Builder - def content_heading_fieldset(legend: { text: "Heading" }) + def content_heading_fieldset(legend: { text: t("activerecord.attributes.katalyst/content/item.heading") }) govuk_fieldset(legend:) do - concat(content_heading_field(label: { text: "Heading", class: "govuk-visually-hidden" })) + concat(content_heading_field(label: { class: "govuk-visually-hidden" })) concat(content_heading_style_field) end end - def content_heading_field(label: { text: "Heading" }, **) - govuk_text_field(:heading, label:, **) + def content_heading_field(**) + govuk_text_field(:heading, **) end - def content_heading_style_field(legend: { text: "Style" }, **) - govuk_enum_radio_buttons(:heading_style, legend:, **) + def content_heading_style_field(**) + govuk_enum_radio_buttons(:heading_style, **) end - def content_url_field(label: { text: "URL" }, **) - govuk_text_field(:url, label:, **) + def content_url_field(**) + govuk_text_field(:url, **) end - def content_http_method_field(label: { text: "HTTP method" }, **) - govuk_enum_select(:http_method, label:, **) + def content_http_method_field(**) + govuk_enum_select(:http_method, **) end - def content_target_field(label: { text: "HTTP target" }, **) - govuk_enum_select(:target, label:, **) + def content_target_field(**) + govuk_enum_select(:target, **) end def content_theme_field(options: { include_blank: true }, **) govuk_enum_select(:theme, options:, **) end - def content_visible_field(label: { text: "Visible?" }, **) - govuk_check_box_field(:visible, label:, **) + def content_visible_field(**) + govuk_check_box_field(:visible, **) end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 6bee8c3..982ce40 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,6 +1,13 @@ en: activerecord: attributes: + katalyst/content/item: + heading: "Heading" + heading_style: "Style" + url: "URL" + http_method: "HTTP method" + http_target: "HTTP target" + visible: "Visible" katalyst/content/figure: heading: "Alternate text" errors: diff --git a/katalyst-content.gemspec b/katalyst-content.gemspec index 8f5dcd6..9b8219c 100644 --- a/katalyst-content.gemspec +++ b/katalyst-content.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |spec| spec.name = "katalyst-content" - spec.version = "3.0.0" + spec.version = "3.0.1" spec.authors = ["Katalyst Interactive"] spec.email = ["developers@katalyst.com.au"]